- #1
zarentina
- 12
- 0
Hello all, I am still new to C++ and was instructed to write four programs all a bit different and eventually combine them into one using a series of nested for loops to get an out put that resembles but goes to 10 lines of output not 5: *NOTE* all these will be separated by a tab cout<<"\t"
* ***** ***** *
** **** **** **
*** *** *** ***
**** ** ** ****
***** * * *****
**Sorry for this the spaces were not showing up between the outputs, they are essentially 4 right triangles rotated and spaced by a tab.**
I have all of the individual programs written, and I can combine the second two without any hiccups yet when I try to combine the first two I begin to run into trouble.
My code for the first two is as follows;
#include<iostream>
using namespace std;
int main ()
{
int i,j,k, range=10;
for (i=0;i<10;i++)
{
for (j=0; j<=i; j++)
{
cout<<"*";
}
cout<<endl;
}
system("pause");
return 0;
}
and the second is:
#include<iostream>
#include <iomanip>
using namespace std;
int main ()
{
int i,j,k, range=10;
for (i=0;i<10;i++)
{
for (j=10; j>i; j--)
{
cout<<"*";
}
cout<<endl;
}
system("pause");
return 0;
}
I'm starting to think maybe my programs for the first two outputs are incorrect? For the second two I simply removed the "cout<<endl;" and replaced it with cout<<"\t"; but this doesn't seem to work for the first two.
Any advice would be greatly appreciated!
Thanks,
Z
p.s sorry for the lengthy post :/
* ***** ***** *
** **** **** **
*** *** *** ***
**** ** ** ****
***** * * *****
**Sorry for this the spaces were not showing up between the outputs, they are essentially 4 right triangles rotated and spaced by a tab.**
I have all of the individual programs written, and I can combine the second two without any hiccups yet when I try to combine the first two I begin to run into trouble.
My code for the first two is as follows;
#include<iostream>
using namespace std;
int main ()
{
int i,j,k, range=10;
for (i=0;i<10;i++)
{
for (j=0; j<=i; j++)
{
cout<<"*";
}
cout<<endl;
}
system("pause");
return 0;
}
and the second is:
#include<iostream>
#include <iomanip>
using namespace std;
int main ()
{
int i,j,k, range=10;
for (i=0;i<10;i++)
{
for (j=10; j>i; j--)
{
cout<<"*";
}
cout<<endl;
}
system("pause");
return 0;
}
I'm starting to think maybe my programs for the first two outputs are incorrect? For the second two I simply removed the "cout<<endl;" and replaced it with cout<<"\t"; but this doesn't seem to work for the first two.
Any advice would be greatly appreciated!
Thanks,
Z
p.s sorry for the lengthy post :/