### easy but confusing!!

hey all :D
I Would like first to thank all the people on this forum for the great help!!

can anyone help me with this problem??

Write a C++ program that prints the squares of all the numbers from 1 to a number n entered by the user. A sample run can be as the following:
Enter a number: 3
1 1
2 4
3 9

here what I did

 ``123456789101112131415161718192021`` ``````#include #include using namespace std; int pow (int x,int y) { return x ; } void main () { int number; cout<<"please enter a number to square \n"; cin>>number; cout<< "the answer is \n"; for (int i=1;i<=number;i++) { cout<

but the result is like:
1 1
2 2
3 3

the power isnt working i guess,
can anyone help??! :D
 ``1234`` ``````int pow (int x,int y) { return x ; }``````

Can you explain how the above is supposed to raise x to the power of y?
 ``12345678910111213`` ``````int pow (int x,int y) { int counter,point_to_x; point_to_x=x; for(counter=1;counter
Last edited on
 ``123456789101112131415161718192021`` ``````#include #include using namespace std; int main () { int number; cout<<"please enter a number to square: "; cin>>number; cout<< "\nthe answer is \n"; for (int i=1;i<=number;i++) { cout << i << " " << i * i <
Last edited on
thank you all for the great help, it worked!!
I was super stupid lol xD
Don't use `system("PAUSE")`.
Use `cin.ignore();` or `cin.get();`
Topic archived. No new replies allowed.