im new to this forum and new to C++.
i had a homework problem about arrays. the user inputs a number and i had to store it in an array. up to now i still don't know how to do it. and then after that i had to find max and min and the average of the array. i tried looking for answers in other threads but couldnt find a specific one that deals with this.

What have you tried? Staring at your keyboard with a dumbfounded expression is unproductive, and I suspect that your teacher wouldn't have given you this assignment without providing any prerequisite information.

Here's a start:

#include <iostream>

int main()
{
    int num;

    while ( std::cin>> num )
        std::cout<< num <<'\n';
}

This reads in numbers until you signal end-of-file or type an invalid number. Now your job is to modify this code so that instead of printing the numbers immediately, the program stores them in an array and then prints them after the loop ends (with another loop).

well i know how to make arrays. we can only use stdio.h library for now and i tried For loops to work with arrays but i couldnt get to do it with the user inputting numbers to go inside the array. i think i need to use while loop for it too but i have no idea how to work it.

You've made two posts in this thread with some complaint about "I can't do it, wah wah wah" and offered no code to prove that you've even tried. No offense, but I'm not encouraged to give you any more help at this point. It's beginning to feel like wasted effort on my part.

>but i have no idea how to work it.
I'm generally happy to help, but I can't give you any answers when you haven't asked any questions. "Do it for me", "tell me how to do it", or any variation thereof does not constitute a question.

This program is simple enough that I can't give you anything more complete than I already have without doing it for you. So are you going to keep crying about how you haven't a clue or are you going to actually try something and ask a specific question that we can answer without feeling guilty that we gave away the answer?

i am sorry if you feel like your efforts were wasted. i dont even think you will open this thread again, Narue. this program is Like a new language for me and it is not simple for me. i haven't heard of it and had no idea of what it was. i just know that i had to take it because it is a requirement.

i just wanted to know the basics of what to do in this problem.

>>i just wanted to know the basics of what to do in this problem.
RTFM.
To be polite, here is are the steps you must take:

1. Construct an Array
2. Ask user how much quantity of data is to be inputed
3. Input all those elements from the user
4. Find the Min and the Max and display them
5. Find the Arithmetic Mean(average what you call) and display it.

Now, the above step may sound too trivial. But I want you to code at least the first two step and post them here.
If you show us your efforts, we will definitely show our help.
Also note, that there are several search engines(Google being most notable) free of cost provided to you. Please use them.
Here is a link I found in just 10 second of Googling, which might be helpful to you in step 3 :
http://www.fredosaurus.com/notes-cpp/arrayptr/array-examples.html

constructing an array is just
int arrayname[];
it doesnt have to be int but the number inside the [] needs to be an integer.
as for how much quantity of inputs it can be any number.
this next statement could be a complaint like what narue said. its up to u how u take it.

i don't know how to answer your question 3 to 5.
if what you mean on 3 is like how to input value on arrays
arrayname[0] = value
that i know

all i know for now is the basics like normal algebra in the program and have little knowledge of the for, while, and if else loops.
iostream is a new library which i don't know if we are gonna be able to use it.

i just found this out

#include <stdio.h>

#define N 30
int main (void)
{
    int i;
    int newary[N];
    int nwr;

    for(i=0; i<N; i++)
    {
        printf("enter a number");
        scanf( "%d", &nwr);
        newary[i] = nwr;
    }

now i need to know how to
1) print all the values of this array
2) find the max and min
3) find the average

Edited 3 Years Ago by Dani: Formatting fixed

Sorry, I won't help,
This is a C code and I am too sure you have not written this yourself(even if you have, I have no respect because it is not in the language supported by this forum i.e. c++. I don't even have respect if you are a C guru.) .
http://www.daniweb.com/forums/announcement8-2.html

Follow what I told you to get a neat help. Also, if you are not well versed even in the basic of c++, you should perhaps follow Clockowl's suggestion and read the tutorial.

I don't think you are following a textbook of c++ because if you were, this problem would not have there.

So it is better to shed some hand on actually typing the code your self (in C++) rather than posting others code.

how come the code works in Microsoft Visual Studio C++ 2008

well i thank you for trying to help. sorry for the trouble that i have caused. i guess i am in the wrong forum then.

and btw what i meant by "I just found this out" is
While in clas, the TA had a review session about arrays and for loops which led me to this idea and tried it out on my own.
i did not look up that code and certainly not a C guru.
actually i am failing the class which led me here

Come on, look at the code closer:

for(i=0; i<N; i++)
{
    printf("enter a number");
    scanf( "%d", &nwr);
    newary[i] = nwr;
}

If the above code fills the array, how would you start by reading it out? Try to find out what each line does and ask if you're in doubt. The reading out part isn't really that difficult if you already got this code your teacher gave you.

ideas given here gives me more ideas

i basically did the for loop again to print the array and it worked hahaXD. thanks guys for helping
all i need now is average but i wont expect anything anymore since now i know that i was talking about C not C++. but thanks for ideas. i will check still but im going to try C forums now

i basically did the for loop again to print the array and it worked hahaXD. thanks guys for helping

Yes! That's exactly what I meant! Good job.

i will check still but im going to try C forums now

I've asked to move this thread to the C-forum

you've "run the program" ? what program? i don't see any program.

and if you really want a suggestion, I suggest you throw Turbo C in the wastebin where it belongs. Use a real compiler that is actually used in industry. Microsoft's Visual C++ or the GNU GCC compiler.

thanks for the people who replied. there was a correction. it was C not C++ my noobidity made me go to C++ and this thread is now in C thanks to niek_e. as for the part of max min and average still want it.

since you've marked this one solved, you might want to create a new thread on how to find min/max/avg of an array of values.

This question has already been answered. Start a new discussion instead.