# include <iostream.h>
int cube(int n=1);int square(int n=1);
int main()
{
int n=1;{
for (n=1;n<=5;n++)
cout<<"number"<<n<<"square"<<square<<"cube"<<cube<<endl;
return 0;}
}
int square(int n)
{
return n*n;
}
int cube(int n)
{
return n*n*n;
}
THis is my program im trying to get the squared and the cube from loop 1to5, but
i wasnt able to get the result Im expecting whats wrong with my program?
it should be like this:
number1square1cube1
number2square4cube8
number3square9cube27
number4square16cube64
number5square25cube125
# include <iostream.h>
int cube(int n=1);
int square(int n=1);
int main()
{
int n=1;
for (n=1;n<=5;n++)
cout<<"number " << n <<" square "<<square(n)<<" cube "<< cube(n)<< endl;
return 0
}
int square(int n)
{
return n*n;
}
int cube(int n)
{
return n*n*n;
}
It works except that theres no semicolon on line 11,I didn't notice my bracket would bring wrong output...anyway thank u so much for helping out....! hope I learn this basic thing as fast as all programmer do, any advice of any reference in this kind of programming!cheers...