Docsity

C++ Program to Print Numbers from 1 to 5 using Loops - Prof. David Jacobs, Study notes of Computer Science

Toggle sidebar
bg1
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

Partial preview of the text

Download C++ Program to Print Numbers from 1 to 5 using Loops - Prof. David Jacobs and more Study notes Computer Science in PDF only on Docsity!

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