What's new
  • Welcome to PHCorner Forums. Take a moment to Sign up and gain unlimited access and extra privileges that guests are not entitled to, such as: All that and more! Registration is quick, simple and absolutely free. Join our community today!

C & C++ Square and Cube a #

avajbt

Addict
Joined
Oct 19, 2014
Messages
369
Reaction
45
Basic C/C++

code:

#include <iostream>
#include <conio.h>

using namespace std;

int main(){

int num;
int prod;
int sqrt;
int cube;

cout<<"Enter A Number: ";
cin>>num;

cout<<"\nn"<<"\tn*2"<<"\tn^2"<<"\tn^3\n"<<endl;

for (int i=1; i<=num; i++)
{

prod= i*2;
sqrt= i*i;
cube= i*i*i;

cout<<i;

cout<<"\t"<<prod;


cout<<"\t"<<sqrt;


cout<<"\t"<<cube<<endl;




}

getch();
return 0;

}
 

Online statistics

Members online
1,465
Guests online
1,242
Total visitors
2,707

Forum statistics

Threads
814,192
Messages
16,105,795
Members
1,437,242
Top