Non-specific homework help

This is a discussion on Non-specific homework help within the C++ Programming forums, part of the General Programming Boards category; hi, here's the question Write a C++ program that takes 2 characters (c and d), and a positive integer (n) ...

  1. #1
    Registered User
    Join Date
    Aug 2010
    Posts
    9

    Unhappy Non-specific homework help

    hi, here's the question
    Write a C++ program that takes 2 characters (c and d), and a positive integer (n) and outputs the following
    drawing of size n  n made of the characters c and d, as shown below:
    Enter two characters and an integer: # _ 6
    #_#_#_
    _#_#_#
    #_#_#_
    _#_#_#
    #_#_#_
    _#_#_#
    Press any key to continue . . .

    here's what did:
    #include <iostream>
    using namespace std;

    int main()
    {
    int n;
    char c, d;
    cout << "Enter two characters and an integer: " << flush;
    cin >> c >> d >> n;

    If anyone could help me..thanks...

  2. #2
    Anti-Poster
    Join Date
    Feb 2002
    Posts
    1,399
    Sure.
    Code:
    #include <iostream>
    using namespace std;
    
    int main()
    {
      int n;
      char c, d;
      cout << "Enter two characters and an integer: " << flush;
      cin >> c >> d >> n;
      //Do some stuff
      return 0;
    }
    I added a return 0 and a closing brace, fixed up the indentation, and used code tags.
    If I did your homework for you, then you might pass your class without learning how to write a program like this. Then you might graduate and get your degree without learning how to write a program like this. You might become a professional programmer without knowing how to write a program like this. Someday you might work on a project with me without knowing how to write a program like this. Then I would have to do you serious bodily harm. - Jack Klein

  3. #3
    Registered User
    Join Date
    Jul 2010
    Location
    Oklahoma
    Posts
    107
    Rcplguy15,

    You'll need to add some flow control too. In fact, the output you provided didn't show a 6 x 6, but a 6 x 4. It should look something like:

    Code:
    for( auto int i = 0; i < n; i++ )   // for each 'row'
    {
       for( auto int j = 0; j < n; j++ )   // for each 'column'
       {
          if( 0 == (i+j) % 2 )   // is it an even or an odd location
          {
              cout << d;
          }
          else
          {
             cout << c;
          }
       }
       cout << endl;
    }
    Best Regards,

    New Ink -- Henry

  4. #4
    Anti-Poster
    Join Date
    Feb 2002
    Posts
    1,399
    Congratulations on finishing someone else's homework, Henry. I'm sure you'll get a good grade.
    If I did your homework for you, then you might pass your class without learning how to write a program like this. Then you might graduate and get your degree without learning how to write a program like this. You might become a professional programmer without knowing how to write a program like this. Someday you might work on a project with me without knowing how to write a program like this. Then I would have to do you serious bodily harm. - Jack Klein

  5. #5
    Registered User
    Join Date
    Jul 2010
    Location
    Oklahoma
    Posts
    107
    Painorain,

    The intention was to clarify...I apologize. I guess I should ask how the test score turns out later? Where are the guidelines about that (homework) in the faq/sticky posts? I guess I should try finding them myself....

    Best Regards,

    New Ink -- Henry

  6. #6
    Anti-Poster
    Join Date
    Feb 2002
    Posts
    1,399
    They're in the announcements on every general programming board. And also here.

    My rule of thumb is to apply as much effort into the answer as the OP has put into asking the question. Reading How To Ask Questions The Smart Way is a big help.
    If I did your homework for you, then you might pass your class without learning how to write a program like this. Then you might graduate and get your degree without learning how to write a program like this. You might become a professional programmer without knowing how to write a program like this. Someday you might work on a project with me without knowing how to write a program like this. Then I would have to do you serious bodily harm. - Jack Klein

  7. #7
    Registered User
    Join Date
    Aug 2010
    Posts
    9
    Hey thanks Harry..Thank u a lot..Nah we don't receive any marks for these questions..It's just the feedback that we receive that counts..we gonna feel the feebacks that we receive in our eportfolio..Thanks a lot..U really generous n good in C++...

  8. #8
    Registered User
    Join Date
    Aug 2010
    Posts
    9
    I mean not feel but enter the feedbacks that we receive...

  9. #9
    Registered User
    Join Date
    Feb 2009
    Posts
    329
    Quote Originally Posted by rcplguy15 View Post
    Hey thanks Harry..Thank u a lot..Nah we don't receive any marks for these questions..It's just the feedback that we receive that counts..we gonna feel the feebacks that we receive in our eportfolio..Thanks a lot..U really generous n good in C++...
    Unless you actually LEARN how to do this, and not copy and paste somebody elses work, you are not going to progress very well.

    This is a very simple problem and one that could easily have been solved with minimal application.

  10. #10
    a_capitalist_story
    Join Date
    Dec 2007
    Posts
    2,639
    So you now have something in your eportfolio that in no way represents your ability. Nice.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Accessing a Specific Text Line Inside CEditView :: MFC
    By kuphryn in forum Windows Programming
    Replies: 2
    Last Post: 04-14-2002, 08:12 PM
  2. Homework
    By kermi3 in forum A Brief History of Cprogramming.com
    Replies: 11
    Last Post: 11-03-2001, 03:39 PM
  3. Homework
    By kermi3 in forum C Programming
    Replies: 10
    Last Post: 09-27-2001, 04:49 PM
  4. Homework
    By kermi3 in forum C++ Programming
    Replies: 15
    Last Post: 09-26-2001, 03:16 PM
  5. Homework
    By kermi3 in forum C Programming
    Replies: 0
    Last Post: 09-10-2001, 01:26 PM

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