1. Computer problem? Tech Support Guy is completely free -- paid for by advertisers and donations. Click here to join today! If you're new to Tech Support Guy, we highly recommend that you visit our Guide for New Members.

Very Basic C++ help

Discussion in 'Software Development' started by amich187, Jan 22, 2009.

Thread Status:
Not open for further replies.
  1. amich187

    amich187 Thread Starter

    Joined:
    Jan 22, 2009
    Messages:
    1
    I am very new to C++, and for my first assignment in a class I am supposed to create a program to create a square shaped figure, with a given character that the user inputs. It's supposed to look like:

    If a is entered as the character:

    EDIT: for some reason it will not let me move the a's or *'s over to the right to make a hollow box shape, but that's how they are supposed to be.

    Code:
    aaaaaa
    a    a
    a    a   
    a    a
    a    a
    aaaaaa
    
    or if * is entered as the character:

    Code:
    ******
    *    *
    *    *
    *    *
    *    *
    ******
    
    I have an idea what I am doing, however, I cannot figure out how to define what character the box is made out of . My code so far is:

    Code:
    /*
    
        Name:
        Class: CIS 150
        Due Date: 1/27/2009    
        Description: This program creates a six by six square, made of a character that is input by the user.
    
    */
    
    #include <iostream>
    using namespace std;
    
    
    int main()
    
    {
              
              char Box;
    
              cout << "Please enter a character: ";
              
              cin >> Box;
    
              cout << Box << Box << Box << Box << Box << Box << endl;
              cout << Box << " " << " " << " " << " " << Box << endl;
              cout << Box << " " << " " << " " << " " << Box << endl;
              cout << Box << " " << " " << " " << " " << Box << endl;
              cout << Box << " " << " " << " " << " " << Box << endl;
              cout << Box << Box << Box << Box << Box << Box << endl;
    
       return 0;
       
    } 
    Now I know this isn't right... can anyone point me in the right direction? Thank you in advance.
     
  2. JimmySeal

    JimmySeal

    Joined:
    Sep 25, 2007
    Messages:
    290
    char Box = Box; should just be char Box;
     
  3. mt2002

    mt2002

    Joined:
    Sep 14, 2005
    Messages:
    919
    Use code tags [ code ]*code here* [/ code ] (without spaces) in the forum to preserve formatting:

    Code:
    aaaaaa
    a    a
    a    a
    a    a
    a    a
    a    a
    aaaaaa
     
As Seen On
As Seen On...

Welcome to Tech Support Guy!

Are you looking for the solution to your computer problem? Join our site today to ask your question. This site is completely free -- paid for by advertisers and donations.

If you're not already familiar with forums, watch our Welcome Guide to get started.

Join over 733,556 other people just like you!

Loading...
Thread Status:
Not open for further replies.

Short URL to this thread: https://techguy.org/793435

  1. This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
    By continuing to use this site, you are consenting to our use of cookies.
    Dismiss Notice