Pankaj makes a program to print the product of cubes of the first 10 whole numbers. She writes the following program: Asked in C,AMCAT
integer x = 0 // statement 1
integer sum = 0 // statement 2
while ( x < 10 ) // statement 3
{
sum = x*x*x // statement 4
x = x + 1 // statement 5
}
print sum // statement 6
Is her program correct? If not, which statement will you modify to correct it?
a. No error, the program is correct.
b. Statement 1
c. Statement 4
d. statement 6
integer x = 0 // statement 1
integer sum = 0 // statement 2
while ( x < 10 ) // statement 3
{
sum = x*x*x // statement 4
x = x + 1 // statement 5
}
print sum // statement 6
Is her program correct? If not, which statement will you modify to correct it?
a. No error, the program is correct.
b. Statement 1
c. Statement 4
d. statement 6