assignment help!!!!!

1)use for loop statement to display
Last edited on
Give it a go and let us know how you go, I'll be happy to help you along then.

Instead of writing the code 10 times, think about how you could put the user input prompt into a "for" or "while" loop, (at each iteration checking how many times it has looped, because you don't want it to ask for more than 10 numbers).
these are two different questions


for the 1st one i used cout<<< but my teacher told me you have to use loop
and i dont know anything about loop

the second one i dont have any ideaaaa



can you give me the code i will get it easily ?
i already worked with my old questions here this site is very interested
Last edited on
Check this out, it explains everything quite well: http://www.cplusplus.com/doc/tutorial/control/
i read it but they nothing special to my queations
Here is the idiom for doing something 10 times:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
const int SIZE = 10;

struct Point {
double X;
double Y;
};

struct Point MyArray[SIZE];  //an array with space for 10 Point structs

for (int a = 0; a < SIZE; a++) {

MyArray[a].X = a; //assign values into the array
MyArray[a].Y = a;

}

//do some calculation on the values in the array

for (int a = 0; a < SIZE; a++) {

MyArray[a].X *= 3.0; //multiply by 3 - same as MyArray[a] = MyArray[a] * 3
MyArray[a].Y *= 5.0;
}

//print out the values in the array

for (int a = 0; a < SIZE; a++) {

std::cout << "X & Y Values " << a << " are " << MyArray[a].X << " " << MyArray[a].Y <<std::endl ;
}



I did the Point struct because that is related to your questions in your other topics.

I just typed this in, I didn't compile it - hopefully I didn't make too many mistakes.

Hop all is well.
Topic archived. No new replies allowed.