c语言 while语句
5.用while语句实现100个2相加。(20分)输入格式:无
输出格式:%d
输入样例:无
输出样例:The sum is 200
程序代码:
[此贴子已经被作者于2023-6-29 14:41编辑过]
#include <stdio.h> int main( void ) { int sum = 0 ; int i = 0 ; while ( i++ != 100 ) { sum += 2 ; } printf( " The sum is %d " , sum ); return 0 ; }
#include <stdio.h> int main( void ) { int sum = 0 ; int i = 0 ; while ( ++i <= 100 ) { sum += 2 ; } printf( " The sum is %d " , sum ); return 0 ; }
[此贴子已经被作者于2023-6-29 17:35编辑过]