|
-
Sep 29th, 2001, 04:38 PM
#1
HELP ME with this......
Hi guys,
I need some help from you using C++.
The problem is.....
to print '*'s. Accept from the user the no. of columns........
for eg: The user enters 5. I need to display...
*
***
*****
***
*
If you observe this........there are 5 columns..........b'cos I entered 5. If the user enters 9, then I need to display these '*'s in 9 cols.....
Hope you guys understood.
I need this........PLEASE..
-
Sep 30th, 2001, 04:37 AM
#2
Member
Hi Amani,
Not sure this is exactly what you are after, but its a start 
#include <iostream.h>
int main()
{
int n = 0;
do
{
cout << "Please enter a odd number!" ;
cin >> n;
if (n%2==0)cout << "You have entered a even number! Please try again." <<"\n";
else cout <<"\n" << "Thanks you.." << "\n\n";
}
while (n%2==0);
for (int i=1;i <= n;i++)
{
for (int y=1, int z=n;y <= i && z >= i ;y++,z--)cout << "*" ;
cout << "\n";
}
return 0;
}
HTH
hmm
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|