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
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
Political Science,
1 month ago
Science,
1 month ago
Math,
3 months ago
Business Studies,
3 months ago
English,
9 months ago
Math,
9 months ago