Tried but nothing coming up. Can you help me with this?

55. After following statements have executed, what will be appear on the output window
int i=0, a=0;
while(i<10){
​a=a+i*i;
​i=i+2;
​cout<<a<<endl;
}

76. After following statements have executed, what will be appear on the output window
int i=10, a=0;
while(i>3){
​a=a+i*i;
​i=i-2;
​cout<<a<<endl;
}


Thanks!
Last edited on
What did you try?


1
2
3
4
5
6
7
8
9
int i=0, a=0; // i==0 and a==0, are they not?

while(i<10) { // i==0 => 0<10, which is true?
​  a=a+i*i; // a=0+0*0
​  i=i+2; // i=0+2 => i==2
​  cout<<a<<endl; // this will appear
}
while(i<10) { // i==2 => 2<10, still true?
​...
Last edited on
Topic archived. No new replies allowed.