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;
}

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 ).

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.

Hi
your question is you just store square rott and cube of first 10 integers.And in your code you get user user input which is incorrect.
First of all you just run a for loop of maximum 10 values in which you do your work e.g square root anf cube anf ten store them in arrays.
If you cannot understand or feel difficulty in coding tell me i will help you and give you a code.

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

for(int i=1;i>=10;i++)
	
for(int i=1;i>=10;i--)

}

besides arrays you should also brush up on for loops...

neither of those will even be entered into (seeing as 1 is NOT greater than or equal to 10). For the first loop you'd need to switch it to this for your code to at least make sense:

for(int i = 0; i < 10; i++)

and your second loop

for(int i = 9; i >= 0; i--);

notice I switched it from going from 1-10 and 10-1 to 0-9 and 9-0 because arrays use a 0 index for the first element. Look over this loop and see if you can get the idea of how it's getting filled

int values[10];

for(int x = 0; x < 10; x++)
{
     values[x] = x+1; //values[0] = 1, ... values[9] = 10

     std::cout << "values[" << x << "] = " << values[x] << std::endl;
}

hope that's helpful

~J

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

Dear I'll try my level best to solve your problem.

//This code store cube of an integer in an array
// declarations
int array[];
int store;
for ( int c=1;c<=10;c++ ) {
      // primary storage 
      store = c*c*c;
    // store cube of the integer in an array
      array [c] = store;
} // for
'c' is the value of an integer which increases as 1,2,3,.......,10.
// Display in reverse order
for (int c=1;c<=10;c++ ) {
     // store value in an array 
     array[c] = c;     
}//for
for (int c=10;c--) {
   // display array in reverse order
        cout << array[c];

}/for

I hope you enjoy it. Any problem tell me.

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.

Don't forget to declare the array as float not int cuz it gonna receive the square roots of the integers which can be float numbers.

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.

Dear

Thanks for your suggestions. I will be care full in the next time.

This article has been dead for over six months. Start a new discussion instead.