C
Programming and Technical
Programming
Definition
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
Read Solution (Total 19)
-
- Answer : 729
Definition: 9*9*9=729 - 10 years agoHelpfull: Yes(8) No(1)
- error in statement 4 as it must be like
sum+(x*x*x) to find the sum of cubes of no. - 10 years agoHelpfull: Yes(3) No(0)
- i think it is one..?
- 9 years agoHelpfull: Yes(2) No(2)
- sum=9*9*9;
- 10 years agoHelpfull: Yes(1) No(1)
- sum value is 729
- 10 years agoHelpfull: Yes(1) No(1)
- 729 is right answer.and if you declare sum=x*x*x as sum=sum+x*x*x then answer will be 2025.
both statements are correct.but both will print different answers - 10 years agoHelpfull: Yes(1) No(0)
- answer:729, Reason:9*9*9
- 10 years agoHelpfull: Yes(1) No(0)
- sum=sum+X*X*X so statement four is wrong
- 10 years agoHelpfull: Yes(0) No(1)
- sum=729
because each time sum take the last valu of x - 9 years agoHelpfull: Yes(0) No(0)
- as x=x+1 , so now x=0+1=1
so now sum=1*1*1=1 - 9 years agoHelpfull: Yes(0) No(0)
- 9*9*9=729,as per quesion
- 9 years agoHelpfull: Yes(0) No(0)
- ans=729
the loop ll execute until x - 9 years agoHelpfull: Yes(0) No(0)
- error
sum=sum+(x*x*x) - 9 years agoHelpfull: Yes(0) No(0)
- in while loop only value of X is changing, value of sum is not
so,when X=9 sum=729 then exit the loop.
so the value of sum is 729 - 9 years agoHelpfull: Yes(0) No(0)
- it gives an error becoz statement 5 appear out of the curly braces.......
- 9 years agoHelpfull: Yes(0) No(1)
- there are some errors in the code
no main, print sum,integer,semi colons
ans is 729
loop repeats and when x becomes 9 then it enters into the loop, updates sum with 9*9*9 and comes out of the loop - 9 years agoHelpfull: Yes(0) No(0)
- Excluding syntax errors, the output will be 729 because while loop will terminate at x=9 so cube of 9 is 729
- 8 years agoHelpfull: Yes(0) No(0)
- 9*9*9 will be printed
- 8 years agoHelpfull: Yes(0) No(0)
- as the while loop will continue till 9th iteration hence it will be 9*9*9=729 and after that it will come out of the loop.
- 8 years agoHelpfull: Yes(0) No(0)
C Other Question