locked
I need help please RRS feed

  • Question

  • I'm new to the programming world. I'm currently going to college for game software development and I'm in my 8th week of my fundamentals of programming class. I would normally go to my instructor, but her responses aren't always quick. Anyways, I'm in need of someone who can explain to me how to do the following:

    Individual assignment:

    When developing more difficult programs, it is important for us to take an incremental approach. We start by developing the simplest program and then we make small modifications to it until it evolves into our final result. Try to keep a functional program at all times.

    First, write a simple program that will read 5 numbers from the Console (user input).  Store these values into an array of int [].  Using the length of the array in a for() loop and decrementing the loop counter, write the array values in reverse order to the screen.   This is step one and may be enough for partial credit. If you have difficulty with this, try seeking some assistance from your instructor before going on to step two.

    Next, add code to read 5 words from the Console (user input).  Store these values into an array of string [].  Make sure the string[] array is large enough to hold at least 6 values. Store the string constant “end_of_array” into the last element of the array. Using a do…while() loop, print out the 1st and 3rd letters of each word (two letters per line) using the substring function.  This is step two and should ensure you at least a passing grade.


    I know how to get the numbers from the console, what I am lost with is how to get them to be stored in an array, or how to use the length of the array in a for() loop for that matter. Even more confusing is how to get it to spit the numbers back out in reverse order. Any help will be greatly appreciated.

    I am using VS C++ Express edition. I hope that some one can help me and explain all this to me so I can get my head wrapped around it and stop feeling like a bone head. Thanks in advance!

    I also want to say that this is online classes, so staying after to get help from the instructor is kind of out of the question.

    StatWC

    • Edited by StatWC Friday, July 18, 2008 9:40 PM adding more info
    Friday, July 18, 2008 9:16 PM

Answers


  • >>what I am lost with is how to get them to be stored in an array

    Review these subjects:

    Lesson 8: Array basics
    http://www.cprogramming.com/tutorial/lesson8.html

    Lesson 8: Arrays
    http://www.cprogramming.com/tutorial/c/lesson8.html

    A Tutorial on Pointers and Arrays in C
    http://cpp.snippets.org/code/ptrtutor.txt

    - Wayne

    • Marked as answer by Yan-Fei Wei Wednesday, July 23, 2008 3:51 AM
    Saturday, July 19, 2008 8:29 PM
  • How are you getting on with your assignment? Here is something to get you started if you still need help

    #include <iostream>
    using namespace std;
        const int n = 5;
    int main (void)
    {
        // Create array of numbers
        int array[n];
        cout << "Give " << n << " numbers:" << endl;
        for(int i = 0; i < n ; i++)
        {
            cin >> array[i];
        }   
        // Write array to the screen
        cout << "Array in reverse order:" << endl;
        for(i = n-1; i >= 0; i--)
        {
            cout << array[i] << " ";
        }
        cin.ignore(1000,'\n').ignore(1000,'\n');
        return 0;
    }
    • Marked as answer by Yan-Fei Wei Wednesday, July 23, 2008 3:52 AM
    Tuesday, July 22, 2008 12:36 PM

All replies

  • Well, you don't seem to think much about your teacher but she came up with an excellent assignment to test your ability to absorb what she tried to teach you.  The notion of storing values in an array is quite fundamental to programming.  Eight weeks of training should have prepped you well to understand the most basic of collection objects. 

    I could give you the answer, but then I'd risk having to teach you these fundamentals when you graduated, with our help, and came to work at my company.  Just as you don't appreciate your teacher much, you probably wouldn't think much of me either.  And I would return the favor.  I think I could avoid all these complications and simply not hire you.  I'd use the same test.

    Hans Passant.
    Friday, July 18, 2008 9:43 PM
  • Please put StatWC on your resume for me.
    Saturday, July 19, 2008 12:29 AM

  • >>what I am lost with is how to get them to be stored in an array

    Review these subjects:

    Lesson 8: Array basics
    http://www.cprogramming.com/tutorial/lesson8.html

    Lesson 8: Arrays
    http://www.cprogramming.com/tutorial/c/lesson8.html

    A Tutorial on Pointers and Arrays in C
    http://cpp.snippets.org/code/ptrtutor.txt

    - Wayne

    • Marked as answer by Yan-Fei Wei Wednesday, July 23, 2008 3:51 AM
    Saturday, July 19, 2008 8:29 PM
  •  First off, this is all done online. I can't just stay after a class and go "Hey tech, can you help me better uderstand this please?" Considering I'm not the only person in this class I'm positive she is getting a ton of questions just like mine from other students filling up her inbox. I have faith in her abilities and I do think highly of her, but when I send a question and it takes a full day or more to get a response, I chose to go elsewhere. somewhere I ran a better chance of getting an answer a bit quicker. I came here asking for some help, not to be talked down to like some kind of moron. I figured I'd come and ask here since you all would know what you're talking about, but I see now that was a big mistake. Thank you so much for the helpful insight as to the lack of my programming abilities. Sorry I'm not up to par in your eyes. Some things take a bit more then "Read your book, and post in the discussion" to grasp without having an actualy person explain it to you. As for working at your company, I'm sure hoping I don't have that pleasure. Besides, what you think means absolutely nothing to me. Thank you for allowing me to waste your prescious time.

    -Wayne, thank you for at least attempting to help me get a better understanding of what I'm supposed to be doing. Your response is the reason I came here with my questions and problems.
    • Edited by StatWC Monday, July 21, 2008 6:18 PM spelling
    Monday, July 21, 2008 6:16 PM
  • StatWC:

    People here will not do your homework for you. The way it works is you post your code, and hopefully someone will help you with why it is not working.


    David Wilkinson | Visual C++ MVP
    Monday, July 21, 2008 7:02 PM
  • How long is your total formation in Game Software Developpement StatWC??
    Monday, July 21, 2008 7:07 PM
  • Eric,

    If you are asking how long have I been at this, the answer is 8 weeks. I just started. I have 3 whole more years to go. If I could have found a good school near me that offered the classes and degree I am going for I would have gone on campus.


    davewilk,

    I'm sorry if it seemed like I was asking people to do my assignments for me. That is not the case. Actually Wayne gave me the most help by directing me to a tutorial that better explained to me how arrays and strings worked. That was what I came here looking for. a better understanding of how it worked. I can do the assignment. i was just at odds with how it was supposed to work in the first place. I should have worded what I was asking better.
    • Edited by StatWC Monday, July 21, 2008 8:57 PM spelling
    Monday, July 21, 2008 8:56 PM
  • How are you getting on with your assignment? Here is something to get you started if you still need help

    #include <iostream>
    using namespace std;
        const int n = 5;
    int main (void)
    {
        // Create array of numbers
        int array[n];
        cout << "Give " << n << " numbers:" << endl;
        for(int i = 0; i < n ; i++)
        {
            cin >> array[i];
        }   
        // Write array to the screen
        cout << "Array in reverse order:" << endl;
        for(i = n-1; i >= 0; i--)
        {
            cout << array[i] << " ";
        }
        cin.ignore(1000,'\n').ignore(1000,'\n');
        return 0;
    }
    • Marked as answer by Yan-Fei Wei Wednesday, July 23, 2008 3:52 AM
    Tuesday, July 22, 2008 12:36 PM