prowessapps.in List of Basic Programs

#include<iostream>
using namespace std;
int main() {
 int a, b, c;
 cout<<"Enter Values of A and B: ";
 cin>>a>>b;
 c = a+b;
 cout<<"Result = "<< c<< endl;
 return 0;
}
OUTPUT
Enter Values of A and B: 10 20
Result = 30

#include<iostream>
using namespace std;
int main(){
 int a, b, temp;
 cout<< "Enter Values of A and B: ";
 cin>>a>>b;
 cout<<"Before Swapping ";
 cout<<"A = "<< a<<" B = "<< b;
 cout<< endl;
 temp = a;
 a = b;
 b = temp;
 cout<<"After Swapping ";
 cout<<"A = "<< a<<" B = "<< b;
 cout<< endl;
return 0;
}
OUTPUT
Enter Values of A and B: 10 20
Before Swapping A = 10 B = 20
After Swapping A = 20 B = 10

#include<iostream>
using namespace std;
int main() {
 int a, b;
 cout<<"Enter Values for A and B: ";
 cin>>a>>b;
 cout<<"Before Swapping ";
 cout<<"A = "<< a<<" B = "<< b;
 cout<< endl;
 a = a+b;
 b = a-b;
 a = a-b;
 cout<<"After Swapping ";
 cout<<"A = "<< a<<" B = "<< b;
 cout<< endl;
return 0;
}

OUTPUT
Enter Values for A and B: 10 20
Before Swapping A = 10 B = 20
After Swapping A = 20 B = 10

#include<iostream>
using namespace std;
int main() {
 int r;
 double area;
 cout<<"Enter Radius: ";
 cin>>r;
 area = 3.14*r*r;
 cout<<"Area = "<< area<< endl;
 return 0;
}

OUTPUT
Enter Radius: 7
Area = 153.86

#include<iostream>
using namespace std;
int main() {
 int a;
 int b;
 cout<<"Enter Number: ";
 cin>>a;
 b = a*a*a;
 cout<<"CUBE = "<< b<< endl;
 return 0;
}

OUTPUT
Enter Number: 5
CUBE = 125

#include<iostream>
#include<math.h>
using namespace std;
int main() {
 int a;
 double b;
 cout<<"Enter Number: ";
 cin>>a;
 b = sqrt(a);
 cout<<"SQUARE ROOT = "<< b;
 return 0;
}
OUTPUT
Enter Number: 5
SQUARE ROOT = 2.3607

#include<iostream>
#include<math.h>
using namespace std;
int main() {
 int x,y,result;
 cout<<"Enter Base: ";
 cin>>x;
 cout<<"Enter Power: ";
 cin>>y;
 result = pow(x,y);
 cout<<"RESULT = "<< result;
 return 0;
}

OUTPUT
Enter Base: 5
Enter Power: 3
RESULT = 125

#include<iostream>
using namespace std;
int main() {
 float c,f;
 cout<<"Enter Temp in (F): ";
 cin>>f;
 c = (5.0/9.0)*(f-32);
 cout<<"Temp in Celcious = "<< c;
 return 0;
}

OUTPUT
Enter Temp in (F): 35
Temo in Celcious = 1.6667

#include<iostream>
using namespace std;
int main() {
 int tms, ts, tm;
 cout<<"Enter Time in millis: ";
 cin>>tms;
 ts = tms/1000;
 tm = ts/60;
 ts = ts%60;
 cout<<"Time- "<< tm<<":"<< ts;
 return 0;
}

OUTPUT
Enter Time in millis: 72014
Time- 1:12

#include<iostream>
using namespace std;
int main() {
 int a,b;
 cout<<"Enter Value for A: ";
 cin>>a;
 cout<<"Enter Value for B: ";
 cin>>b;
 (a>b)?cout<<"A is Greater":cout<<"B is greater ";
 return 0;
}

OUTPUT
Enter Value for A: 10
Enter Value for B: 20
B is Greater

#include<iostream>
using namespace std;
int main() {
 int a,b,diff;
 cout<<"Enter value for A: ";
 cin>>a;
 cout<<"Enter value for B: ";
 cin>>b;
 diff = (a>b)?(a-b):(b-a);
 cout<<"Diff. = "<< diff;
 return 0;
}

OUTPUT
Enter Value for A: 10
Enter Value for B: 20
Diff. = 10





CONTACT DETAILS

info@prowessapps.in
(8AM to 10PM):

+91-9026070669 , +91-9451396824

© 2016, prowessapps.in, All rights reserved