Please help, i need a program that reads the side of a square and prints a square of that size out of astericks, i appreciate a hint to get started, thanks, Ben
Please help, i need a program that reads the side of a square and prints a square of that size out of astericks, i appreciate a hint to get started, thanks, Ben
Hi,
1)read the value the user inputs and store it in a variable say x.
int x= ans;
2) introduce a "for loop" for that no. of times , counter<=x
3)introduce a another "for loop" inside the above loop .
4)and type cout<<"*";
5)close the inner loop
6)type cout<<endl;//for printing 1 line of stars and coming to new line
7)close the outer loop
8)return 0;
I hope it helps!!
BEST LUCK.
in the game programming board there is a question on rectangle quite similar to this check that out and modify it to suit your needs
-
Hey i just wisked this up, it should help with your home work
Code:#include <iostream.h> #include <iomanip.h> int main() { int len; cout<<"\nEnter Square side length: "; cin>>len; cout<<endl<<endl; cout<<"Printed Square:\n"; cout<<"---------------\n\n\n"; for(int j = 0; j < len; j++) { cout<<setw(10); for(int i = 0; i < len; i++) { cout<<"*"; } cout<<endl; } cout<<endl<<endl; return 0; }
TNT
You Can Stop Me, But You Cant Stop Us All
You just did the program for him. The point is that you're supposed to help him understand the concepts...not GIVE him the program =POriginally posted by (TNT)
Hey i just wisked this up, it should help with your home work
Code:#include <iostream.h> #include <iomanip.h> int main() { int len; cout<<"\nEnter Square side length: "; cin>>len; cout<<endl<<endl; cout<<"Printed Square:\n"; cout<<"---------------\n\n\n"; for(int j = 0; j < len; j++) { cout<<setw(10); for(int i = 0; i < len; i++) { cout<<"*"; } cout<<endl; } cout<<endl<<endl; return 0; }