Nested loop in c++ [Solved] | Sololearn: Learn to code for FREE!
Nouvelle formation ! Tous les codeurs devraient apprendre l'IA générative !
Essayez une leçon gratuite
+ 2

Nested loop in c++ [Solved]

Output should be like this: 12345 13579 1471013 Here is the code int i ,j; For(i=1;i<=5;i++){ For(j=1;j<=5;j++){ cout<<j; } Cout<<endl; } Here it will print from 1 upto 5 five times, but i want to change other lines as well.

30th Jun 2020, 9:55 AM
sadia aslamy
sadia aslamy - avatar
3 Réponses
+ 1
Try: cout<<i*(j-1)+1
30th Jun 2020, 10:07 AM
Alexander Thiem
Alexander Thiem - avatar
0
Alexander Thiem Thank you so much
30th Jun 2020, 10:13 AM
sadia aslamy
sadia aslamy - avatar
0
You are welcome
30th Jun 2020, 11:01 AM
Alexander Thiem
Alexander Thiem - avatar