Square

This is a discussion on Square within the C++ Programming forums, part of the General Programming Boards category; Please help, i need a program that reads the side of a square and prints a square of that size ...

  1. #1
    Registered User
    Join Date
    Apr 2002
    Posts
    1

    Unhappy Square

    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

  2. #2
    Unregistered
    Guest
    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.

  3. #3
    I'm Back
    Join Date
    Dec 2001
    Posts
    556
    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

  4. #4
    Registered User (TNT)'s Avatar
    Join Date
    Aug 2001
    Location
    UK
    Posts
    339
    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

  5. #5
    Registered User
    Join Date
    Mar 2002
    Posts
    23
    Originally 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;
    }
    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 =P

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Tic Tac Toe Comp Move help
    By swgh in forum C++ Programming
    Replies: 5
    Last Post: 09-24-2008, 12:05 PM
  2. Loop seg error
    By Zishaan in forum Game Programming
    Replies: 2
    Last Post: 03-28-2007, 02:27 PM
  3. Forced moves trouble!!
    By Zishaan in forum Game Programming
    Replies: 0
    Last Post: 03-27-2007, 07:57 PM
  4. Help with my draughts game
    By Zishaan in forum C++ Programming
    Replies: 9
    Last Post: 03-24-2007, 08:33 AM
  5. C++ Checkers Game
    By SnS CEO in forum C++ Programming
    Replies: 9
    Last Post: 09-07-2005, 02:21 AM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21