Question

# 1. Identify and correct the errors in each of the following statements: a) for (a =...

1. Identify and correct the errors in each of the following statements:

a)

for (a = 25, a <= 1, a--); {printf("%d\n", a);}

b) The following code should print whether a given integer is odd or even:

switch (value) {case (value % 2 == 0):puts("Even integer");case (value % 2 != 0):puts("Odd integer");}

c) The following code should calculate incremented salary after 10 years:

for (int year = 1; year <= 10; ++year) {double salary += salary * 0.05;}printf("%4u%21.2f\n", year, salary);

d)

for (double y = 7.11; y != 7.20; y += .01)printf("%7.2f\n", y);e) The following code should output all multiples of 3 from 1 to 100:for (int x = 3; x <= 100; x%3 == 0; x++ ) {printf("%d\n", x);}

e) The following code should output all multiples of 3 from 1 to 100:

for (int x = 3; x <= 100; x%3 == 0; x++ ) {printf("%d\n", x);}

the loop will never execute as the condition is false
corrected Code:
for (a = 25, a >= 1, a--); {printf("%d\n", a);}

switch (value%2) {
case 0:
puts("Even integer");
break;
case 1:
puts("Odd integer");}
break;
}

double salary=1000;
for (int year = 1; year <= 10; ++year) {
salary+= salary * 0.05;
}
printf("%4u%21.2f\n", year, salary);

for (int x = 3; x <= 100; x+=3 ) {
printf("%d\n", x);
}
for (int x = 3; x <= 100; x+=3 ) {
printf("%d\n", x);
}

#### Earn Coins

Coins can be redeemed for fabulous gifts.