I want to get the following output using nestted loops ...c++ ...please can anyonehelp? | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
+ 1

I want to get the following output using nestted loops ...c++ ...please can anyonehelp?

1 3 5 5 7 9 7 9 11 13

2nd Jan 2017, 12:25 PM
hussain nagaria
hussain nagaria - avatar
2 Answers
+ 8
The following are codes that I have written to suit your needs, however, I am not really sure how to explain them to you... You may try to examine the codes first and if you come up with any questions, I will try to answer you. #include <iostream> using namespace std; int main() { int i = 0; int j = 1; int k = 2; int l = 1; for (i = 0; i < 4; i++) { for (j = l; j < k; j += 2) { cout << j << " "; } cout << endl; l = l + 2; k = k + 4; } return 0; }
2nd Jan 2017, 1:12 PM
Hatsy Rei
Hatsy Rei - avatar
+ 2
a huge thanks to you I understood it very clearly....thanks
2nd Jan 2017, 1:20 PM
hussain nagaria
hussain nagaria - avatar