help me on this tutorial
heey guys..
i just learned the arrays.. am not really good at them..
can some one simplify it for me..
i gat this question.. i tried to solve it.. but didn't get the desired output :S
how ever it says 1 succeeded !
here's the Q:
1. Declare one array for storing the square roots of the integers from 0 through 10.
2. Declare one array for storing the cubes of the same integers.
3. Write a program that reads 10 integers and prints them in reverse order .
this is my work.. i'm pretty sure it's wrong..
#include <iostream>
using namespace std;
int main ()
{
int SQUARE_ROOTS [10];
cout<<"Enter 10 numbers:"<<endl;
for(int i=1;i>=10;i++)
cin>>SQUARE_ROOTS [i];
for(int i=1;i>=10;i--)
cout<<"The numbers in reverse order are:"<<endl
<<SQUARE_ROOTS [i];
return 0;
}
fadia
Junior Poster in Training
89 posts since Apr 2009
Reputation Points: 7
Solved Threads: 0
You shouldn't read in a square root or a cube. You CALCULATE the square root or the cube. Thus this is incorrect:
cout<<"Enter 10 numbers:"<<endl;
for(int i=1;i>=10;i++)
cin>>SQUARE_ROOTS [i];
Don't read in data into the SQUARE_ROOTS array. You shouldn't be reading numbers in from the user in this part of the program anyway.1. Declare one array for storing the square roots of the integers from 0 through 10.
2. Declare one array for storing the cubes of the same integers.
The numbers range from 0 to 10. There is no need to ask for user input.
You ask for user input in the third part.3. Write a program that reads 10 integers and prints them in reverse order .
but that has nothing to do with cubing or taking a square root, so create a different array and call it something different (i.e. userInput ).
VernonDozier
Posting Expert
5,527 posts since Jan 2008
Reputation Points: 2,633
Solved Threads: 711
i didn't really understood that..
thanks though
fadia
Junior Poster in Training
89 posts since Apr 2009
Reputation Points: 7
Solved Threads: 0
i didn't really understood that..
thanks though
There's not much anyone can do with this post. The obvious question is "What part of my post don't you understand?" We aren't mind readers and posting on a forum requires some effort on your part. You need to ask a specific question.
VernonDozier
Posting Expert
5,527 posts since Jan 2008
Reputation Points: 2,633
Solved Threads: 711
yeah i'm having some difficulties to understand anything written.. i need some examples to get a certain idea.. if u don't mind give me an example for a similar question..
thnks
fadia
Junior Poster in Training
89 posts since Apr 2009
Reputation Points: 7
Solved Threads: 0
Any problem tell me.
Three problems. One, use code tags. Two, don't give away all the code. Give hints and advice. Three, if you decide to give away all the code, make sure it's code that compiles.
VernonDozier
Posting Expert
5,527 posts since Jan 2008
Reputation Points: 2,633
Solved Threads: 711