Computer Science, asked by sarahbhatt08gmailcom, 3 months ago

Write down the output of the following:(C++)
int a = 1, sq = 1;
while (a<=15)
{
sq=a*a
cout <<a <<" "<< endl;
cout<<sq<<" ";
a+=2;
}​

Answers

Answered by anindyaadhikari13
1

Output:

Output for the given códe is,

1

1 3

9 5

25 7

49 9

81 11

121 13

169 15

225

Explanation:

  • Initially a = 1. After each iteration, value of a is incremented by 2.
  • After each iteration, value of variable 'a' is displayed and then, it moves to the new line.
  • After moving to the new line, it displays the square of a.
  • When a becomes greater than 15, loop is terminated.
Similar questions