i am going to tell the first one only,you can try the rest by yourself.
think of first figure as four triangles!
1.thats counts and prints in ascending order
2.thats counts and prints in descending order
3.one that prints spaces " " in ascending order
4.this one also prints spaces " " in ascending order
first of all determine the number of rows you want to print.
here we have 5
so this means we will have to make an outer loop that runs 5 times
,then come the nested loops!....
then all you have to do is,check all the conditions.do some dry runs on your copy first.this way you will understand!
you wont be able to do this unless you try it yourslef!
just practice practice and practice!
here is the code,i had a similar assignment ,way back.changed it a bit.but it prints "5" twice,you figure it out yourself!
for(int x=5;x>0;x--)
{
for(int b=0;b<x;b++)
{
cout << b+1;
}
for(int c=5;c>x;c--)
{
cout << " ";
}
for(int e=4;e>x;e--)
{
cout << " ";
}
for(int d=x;d>0;d--)
{
cout << d;
}
cout << endl;
}
this is just for learning,try to make your own codes!