>i'm prepared to listen and learn.i'm not here to copy any stqatements i'm here tyo learn
>and also this programming has to be done using if statement only
That's exactly why I think you're meant to use recursion. The only other way is to write the code inline:
int main()
{
// Print the square and cube of 0
// Print the square and cube of 1
// Print the square and cube of 2
...
// Print the square and cube of 9
}
That doesn't use an if statement, and neither does your current solution. So my conclusion is that you need to approximate this:
int main()
{
for ( int i = 0; i < 10; i++ ) {
// Print the square and cube of i
}
}
Which can be done with a recursive function using an if statement as the base case:
void f ( int i )
{
if ( i < 10 ) {
// Print the square and cube of i
f ( i + 1 );
}
}
int main()
{
f ( 0 );
}
>you can just write
>using namspace std;
That's generally considered a bad practice though because it opens up names that you don't use and defeats the purpose of namespaces in avoiding naming collisions.
>but still whenever i compile this program it is leaving this numbers in
>between so i don't know how to deal with that.
The numbers in between are the user input being echoed to the screen. You can avoid it by requiring the user to enter all numbers immediately and then simply not prompting further:
int main()
{
int x, y, z;
cout<<"Enter three numbers: ";
cin>> x;
cout<< x <<'\n';
cin>> y;
cout<< y <<'\n';
cin>> z;
cout<< z <<'\n';
}