- 3
What is the code of this output
11112 2223 334 45 5 Loops in c++
10 Answers
+ 2
Thanks for the idea
+ 1
Thank you so much AJ have a great night
0
Can you post your attempt?
0
#include <iostream>
using namespace std;
int main() {
int x=0;
for(int i=5;i>0;)
{
if(x<i)
{cout<<"1";
x++;
continue;}
cout<<endl;
i--;
x=0;
}
return 0;
}
0
Can anyone help me
0
Bacani Rocelle M.
Just a little change, played with a variable instead of hard code value
https://code.sololearn.com/c1tvTXVRSgV7/?ref=app
0
AJ can you help to learn looping this code is a little bit hard for me im still learning loopings
0
This is my while loops can you do a do while
0
#include <iostream>
#include <conio.h>
using namespace std;
int main ()
{
int x=1;
while (x<=4)
{
int y=4;
while (y>=x)
{
cout<< x;
y--;
}
x++;
cout<<x;
cout<<endl;
}
cout<<x;
getch ();
return 0;
}
0
Bacani Rocelle M.
It is simple just put first while later and replace with do
#include <iostream>
using namespace std;
int main ()
{
int x=1;
do//updated
{
int y=4;
while (y>=x)
{
cout<< x;
y--;
}
x++;
cout<<x;
cout<<endl;
} while (x<=4); //added
cout<<x;
return 0;
}