// Calculate the sum of the integers from 1 to 10
#include <stdio.h>
int main( void )
{
unsigned int sum, x; // define variables sum and x
x = 1; // set x
sum = 0; // set sum
while ( x <= 10 ) { // loop while x is less than or equal to 10
sum += x; // add x to sum
++x; // increment x
} // end while
printf( "The sum is: %u\n", sum ); // display sum
} // end main function






0 comments:
Post a Comment