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
#include <iostream>
#include <cmath>
usingnamespace 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<<i<<" "<<pow(i,2)<<endl;
}
system ("pause");
}
but the result is like:
1 1
2 2
3 3
the power isnt working i guess,
can anyone help??! :D
#include <iostream>
#include <cstdlib>usingnamespace 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 <<endl;
}
system ("pause");
}