1.1 Which of the following program segments will display odd numbers up until to 31?
a. i = 1;
while (i < 31)
{ cout << "i = " << i << endl; i = i + 2; }
b. for(int i= 0; i < 32 ; i++)
{ cout << "i = " << i << endl; }
c. for(int i= 0; i <= 31 ; i= i + 2 )
{ cout << "i = " << i << endl; }
d. for(int i= 1; i < 32 ; i= i + 2 )
{ cout << "i = " << i << endl; }
The segment "d" will display odd numbers up until to 31
Comments
Leave a comment