Need help with simple program!

I can't understand my computer science teacher and I need help writing these programs!

1. Write a program that reads 5 numbers from a user into a one-dimensional array and outputs them to the screen in both forward and backward order. This program should allow the user to enter as many sets of 5 numbers as they would like.

2. Write a program that always takes the numbers 1-20 and stores them into a one-dimensional array. The program should then take each number in the array and based on if that number is even or odd, place it in the first free space in one of two other one-dimensional arrays called Even and Odd. The the program should output the two arrays (Even/Odd) under an aptly named column heading.

I desperately need the var sections and main sections of these codes! Help on either problem would be highly appreciated!

I use Microsoft Visual Studio 2010 if that helps to narrow down any kind of unnecessary syntax that is incompatible with that software.
Last edited on
So, uh, you want us to do the programs for you, am I right?
Pretty much.
closed account (zb0S216C)
ProgramminNewby wrote:
can't understand my computer science teacher and I need help writing these programs! (sic)

Bring your difficulty to your teachers attention. Maybe then you'll receive assistance.

For No. 1, look into arrays, loops, and I/O. I'll provide some links.

I'll get you started with some easy-to-read code:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
int main()
{
    Declare an array of [5] integers = {set them to zero};
 
    while(the user has the console open)
    {
        for(Loop until 5 integers have been extracted from the input buffer)
            Place the extracted integer into the next available space in the array;

        for(Loop until 5 cycles have passed)
            Start at the back of the array and print each integer accordingly;

        for(Loop until 5 cycles have passed)
            Start at the front of the array and print each integer accordingly;
    }

    Return from main();
}


References:

Arrays: http://www.cplusplus.com/doc/tutorial/arrays/
I/O: http://www.cplusplus.com/doc/tutorial/basic_io/
Loops: http://www.cplusplus.com/doc/tutorial/control/


Edit: Actually adding the links would've been helpful :)P

Wazzak
Last edited on
Is there some reason you are taking a programming class? I mean, solving puzzles like this is pretty much all programming is, correct?
Thank you Framework! And @interputed, I had no idea the class I signed up for was programming (it was called Computer Science) and so I thought "Hey! I'm good at typing and with Microsoft Office, so why not?!" Sorely mistaken :(
Topic archived. No new replies allowed.