1. Program to print to print “WELCOME “WELCOME IN C++”. C++”. #include void main() { cout <<"Welcome in C++ Programming"; }
OUTPUT
Welcome in C++ Programming.
2. Program to find sum of two numbers. #include void main() { int num1,num2,sum; cout<<"Enter Number 1: "; cin>>num1; cout<<"Enter Number 2: "; cin>>num2; sum=num1+num2; cout<<"Sum of numbers: "<
OUTPUT
Enter Number 1: 5 Enter Number 2: 6 Sum of numbers: 11
3. Program to find square of a number. #include void main() { int num1,square; cout<<"Enter number: "; cin>>num1; square=num1*num1; cout<<"Square of number is: "<
OUTPUT
Enter number:
5
Square of number is: 25
4. Program to check whether a number is greater than or less than other number. #include #include void main() { clrscr(); int num1,num2; cout<<"Enter value for num 1: ”; cin>>num1; cout<<"Enter value for num 2: "; cin>>num2; if(num1>num2) cout<<"Num1 is greater than num 2"; else cout<<"Num1 is smaller than num 2"; }
OUTPUT
Enter value for num 1: 5 Enter value for num 2: 10 Num1 is smaller smaller than num 2
5. Program to calculate percentage marks for three subjects. #include void main() { float English, Maths, Science, Sum, Percentage; cout<<"Enter marks of Subject ENGLISH, MATHS & SCIENCE: "; cin>>English>>Maths>>Science; Sum=English+Maths+Science; Percentage=Sum*100/300; cout<<"Percentage cout<<"Percentage = "<
OUTPUT Enter marks of Subject Su bject ENGLISH, MATHS & SCIENCE: 90 98 95 Percentage = 94.33333333
6. Program that reads temperature in Celsius and displays it in Fahrenheit. #include void main() { int Celsius, Fahrenheit; cout<<"Enter temperature in degree CELCIUS:
";
cin>>Celsius; Fahrenheit=9*Celsius/5+32; cout<<"Temperature in degree FAHRENHEIT: }
OUTPUT
Enter temperature in degree CELCIUS:
40
Temperature in degree FAHRENHEIT:
104
"<
7. Program that reads radius of a circle and prints its area. #include void main() { float radius,area; cout<<"Enter Radius of circle:
";
cin>>radius; area=radius*3.14*radius; cout<<"Area of Circle:
"<
}
OUTPUT
Enter Radius of circle: Area of Circle:
14
615.44
8. Program that enter value of x from user and prints Y = 2x and Z = 2x -1. #include #include void main() { clrscr(); int x,y,z; cout<<"Enter x: "; cin>>x; y=2*x; z=2*x-1; cout<<" Y = "<>totaldays; years=totaldays/365; rem1=totaldays%365; weeks=rem1/7; rem2=rem1%7; days=rem2; cout<<"Years = "<
OUTPUT Enter total total number of days : 956 Years = 2
weeks = 32
days = 2
10. Program for swapping of two numbers using third number. #include #include void main() { clrscr(); int a, b, c; cout<<"Enter a : "; cin>>a; cout<<"Enter b : "; cin>>b; c=a; a=b; b=c; cout<<"\na= "<
OUTPUT Enter a: 5 Enter b: 7 a= 7 b= 5