
Study with the several resources on Docsity
Earn points by helping other students or get them with a premium plan
Prepare for your exams
Study with the several resources on Docsity
Earn points to download
Earn points by helping other students or get them with a premium plan
The code for a c++ program that prints numbers from 1 to 5 using different types of loops: a for loop, a while loop, and two nested for loops. The program demonstrates how to control the flow of execution using loop structures.
Typology: Study notes
1 / 1
This page cannot be seen from the preview
Don't miss anything!

For (int I = ; I <= 5; I = I + 1) { Sopl(i); (prints 1,2,3,4,5) While (i<=5){ Sopl(i); I = I + 1; For (int I = 1; I <= 5; I = I + 1){ For (int j = 1; j <= i; j = j + 1){ Sop(j); }sop(‘\n’); 1 12 123 1234 12345 For( int I = 5; I >= 5; I = I - 1){ For(int j = 1; j <= i; j = j + 1){ Sop(j); }sop(‘\n’); 12345 1234 123 12 1