Q1
#include<iostream>
using namespace std;
int main()
float centigrade;
float fahrenheit;
cout<< "Enter temp. in Centigrade: ";
cin>>centigrade;
cout<<endl;
fahrenheit = (centigrade*9/5) + 32;
cout<<"Temp. in fahrenheit: "<<fahrenheit;
return 0;
Q2
#include<iostream>
using namespace std;
int main() {
int a=10, b=30, sam;
cout<< "Before swapping." << endl;
cout<< "a = " << a << ", b = " << b << endl;
sam = a;
a = b;
b = sam;
cout<< "\nAfter swaping." << endl;
cout<< "a = " << a << ", b = " << b << endl;
return 0;
Q3
#include<iostream>
using namespace std;
int main() {
float n1, n2, n3;
cout << "Enter three numbers: ";
cin>> n1 >> n2 >> n3;
if(n1 >= n2 && n1 >= n3)
cout << " Largest number: " << n1;
if (n2 >= n1 && n2 >= n3)
cout << " Largest number: " << n2;
if(n3 >= n1 && n3 >= n2)
cout << " Largest number: " << n3;
return 0;
Q4
#include <iostream>
using namespace std;
int main ()
int a,b,c;
cout<<"Enter three integers :";
cin>>a>>b>>c;
cout<<endl;
if (a>b && b>c) {
cout<<c<<" "<<b<<" "<<a;
}
else if (a>c && c>b)
cout<<b<<" "<<c<<" "<<a;
else if (b>a && a>c)
cout<<c<<" "<<a<<" "<<b;
else if (b>c && c>a)
cout<<a<<" "<<c<<" "<<b;
else if (c>a && a>b)
cout<<b<<" "<<a<<" "<<c;
else cout<<a<<" "<<b<<" "<<c;
cout<<endl;
Q5
#include <iostream>
using namespace std;
int main() {
int year;
cout<< "Enter a year: ";
cin>> year;
if (year%4 == 0) {
if(year%100 == 0) {
if(year%400 == 0)
cout<<year<< " is a leap year,";
else
cout<<year<< " is not a leap year.";
else
cout<<year<< " is a leap year.";
else
cout<<year<< " is not a leap year.";
return 0;
Q6
using namespace std;
int main()
{
int shyam_age,laxman_age,tony_age;
cout<< "Enter Shyam age:";
cin>>shyam_age;
cout<< "Enter Laxman age:";
cin>>laxman_age;
cout<< "Enter Tony age:";
cin>>tony_age;
if (shyam_age<laxman_age && shyam_age)
cout<<"Shyam is youngest";
else if(laxman_age<shyam_age && laxman_age<tony_age)
cout<<"Laxman is youngest";
else
cout<<"Tony is youngest";
return 0;
Q7
#include <iostream>
using namespace std;
int main()
{
float bs,gs,da,hra;
cout<<"Please Entered Basic Salary (In Rs.): ";
cin>>bs;
if (bs<1800)
hra = bs * 15 / 100;
da = bs * 70 / 100;
else
hra = 600;
da = bs * 88 / 100;
gs = bs + hra + da;
cout<<"Basic Salary Rs. "<<bs<<endl;
cout<<"HRA Rs. "<< hra<<endl;
cout<<"DA Rs. "<< da<<endl;
cout<<"Gross salary Rs. " << gs<<endl;
return 0;
}
Q8
using namespace std;
int main()
int sub1,sub2,sub3,sub4,sub5,percentage;
cout<<"Enter marks of five subjects : ";
cin>>sub1>>sub2>>sub3>>sub4>>sub5;
percentage=(sub1+sub2+sub3+sub4+sub5)/5;
if(percentage>=60)
cout<<"First division";
else if(percentage>=50)
cout<<"Second division";
else if(percentage>=40)
cout<<"Thirdrd division";
else
cout<<"Fail" ;
return 0;