Question: 1. Identify and correct the errors in each of the following statements. (Note: There may be more than one error per statement.) k) if(age>=65); {
1. Identify and correct the errors in each of the following statements. (Note: There may be more than one error per statement.)
k) if(age>=65); { printf( "Age is greater than or equal to 65" ); } else { printf( "Age is less than 65" ); } l) int x = 1, total; while ( x <= 10 ) { total += x; ++x; } m) While(x<=100) total += x; ++x; n) while ( y > 0 ) { printf( "%d ", y ); ++y; } o) For(x=100,x>=1,++x) { printf( "%d ", x ); } p) for ( x = .000001; x == .0001; x += .000001 ) { printf( "%.7f ", x ); } q) The following code should output the odd integers from 999 to 1: for ( x = 999; x >= 1; x += 2 ) { printf( "%d ", x ); } r) The following code should sum the integers from 100 to 150 (assume total is initialized to 0): for ( x = 100; x <= 150; ++x ); { total += x; }
2. What does the following program print?
#include
int main( void )
{
unsigned int x = 1, total = 0, y;
while ( x <= 10 ) {
y = x * x;
printf( "%d ", y );
total += y;
++x;
} // end while
printf( "Total is %d ", total );
} // end main
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
