Thread: Assignment help please

  1. #1
    Registered User
    Join Date
    Feb 2014
    Posts
    2

    Post Assignment help please

    Hi all,

    im a total noob having to take C++ as part of my design course please help me!

    Start with this code:
    Code:
    #include <iostream> 
    using namespace std; 
    int main() 
    { 
    int x = 5; 
    for ( int r = 0; r < x; r++ ) 
    { 
    for ( int c = 0; c < x; c++ ) 
    { 
    if ( c == 0 || c == x - 1 || r == 0 || r == x - 1) 
    cout << "*"; 
    else 
    cout << " "; 
    }// inner for 
    cout << endl; 
    }// outer for 
    } 
    (b) Using while loop, modify the program in Table 1.

    (c) You noted that the value of x is hard-coded and the program in Table 1 executes only once. Amend the program in Part (b) to allow data entry for the variable x and repeats the execution until the user enters the sentinel value, -1 to exit the program. Comment your code for this Part (c).

    Please help me with the code guys i would really appreciate it

  2. #2
    C++まいる!Cをこわせ!
    Join Date
    Oct 2007
    Location
    Inside my computer
    Posts
    24,654
    Be a little more specific about what you're having trouble with.
    Quote Originally Posted by Adak View Post
    io.h certainly IS included in some modern compilers. It is no longer part of the standard for C, but it is nevertheless, included in the very latest Pelles C versions.
    Quote Originally Posted by Salem View Post
    You mean it's included as a crutch to help ancient programmers limp along without them having to relearn too much.

    Outside of your DOS world, your header file is meaningless.

  3. #3
    Registered User
    Join Date
    Feb 2014
    Posts
    2
    to be honest my friend, i know nth about c++ its my first time doing it and my lecturer is teaching like a speed train, im at a lost right now

  4. #4
    and the hat of int overfl Salem's Avatar
    Join Date
    Aug 2001
    Location
    The edge of the known universe
    Posts
    39,659
    I suppose the first thing to realise is that

    Code:
    for ( a ; b ; c ) {
      d;
    }
    Can be written as
    Code:
    a;
    while ( b ) {
      d;
      c;
    }
    If you dance barefoot on the broken glass of undefined behaviour, you've got to expect the occasional cut.
    If at first you don't succeed, try writing your phone number on the exam paper.

  5. #5
    C++まいる!Cをこわせ!
    Join Date
    Oct 2007
    Location
    Inside my computer
    Posts
    24,654
    Quote Originally Posted by KC Teo View Post
    to be honest my friend, i know nth about c++ its my first time doing it and my lecturer is teaching like a speed train, im at a lost right now
    That sucks. But unfortunately, we cannot teach you the entire C++.
    The only things I can suggest are that you try to work out some solution with your lecturer or do self-studies with a good book. Good books can be found here: C++ Book Recommendations
    Quote Originally Posted by Adak View Post
    io.h certainly IS included in some modern compilers. It is no longer part of the standard for C, but it is nevertheless, included in the very latest Pelles C versions.
    Quote Originally Posted by Salem View Post
    You mean it's included as a crutch to help ancient programmers limp along without them having to relearn too much.

    Outside of your DOS world, your header file is meaningless.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Help on my Assignment Please :C
    By l2krence in forum C Programming
    Replies: 2
    Last Post: 11-03-2010, 10:31 PM
  2. Replies: 3
    Last Post: 04-26-2009, 08:54 AM
  3. assignment help
    By mb86 in forum C Programming
    Replies: 8
    Last Post: 04-20-2008, 03:24 PM
  4. need help for assignment,Please!!!
    By jojo13 in forum C++ Programming
    Replies: 7
    Last Post: 03-31-2008, 05:11 AM
  5. First assignment help
    By FirstC++ in forum C++ Programming
    Replies: 7
    Last Post: 07-01-2004, 07:57 AM

Tags for this Thread