Q1.
Write a program that will take input of two numbers from user and will show
result of addition, subtraction, multiplication, division and remainder.
Program
Code:
#include <iostream>
#include <conio.h>
using namespace std;
int main()
{
float x,y,z;
cout<<
"Enter a Number: ";
cin>> x;
cout<<"Enter
another Number: ";
cin>>y;
z=x+y;
cout<<"Addition
is "<<z<<endl;
z=x-y;
cout<<"Subtraction
is "<<z<<endl;
z=x*y;
cout<<"Multiplication
is "<<z<<endl;
z=x/y;
cout<<"Division
is "<<z<<endl;
getche ();
return 0;
}
Q2.
Write a program that will take two inputs in Kilogram and Height of a person
and program will calculate its BMI (body mass index).Display BMI as output.
Program
Code:
#include <iostream>
#include <conio.h>
using namespace std;
void main()
{
float x,y,z,d;
cout<<"Enter mass in kg: ";
cin>>x;
cout<<"Enter Height in cm: ";
cin>>y;
z=y/100;
d=x/(z*z);
cout<<"Body Mass Index(BMI) = "<<d;
getche();
}
Q3.
Write a program that will take input cm (centimeter) value from user and
program will convert in
Inches
Foot
Meter
Yard
Kilometer
Miles
Display
all these values as output.
Program Code:
#include <iostream>
#include <conio.h>
#include <math.h>
using namespace std;
int main()
{float x,y;
cout<<"Enter
a number in cm: ";
cin>>x;
y=x*0.39370;
cout<<"The
Number in inches is "<<y<<endl;
y=x * 0.032808;
cout<<"The
Number in Foot is "<<y<<endl;
y=x/100;
cout<<"The
Number in meters is "<<y<<endl;
y=x * 0.010936;
cout<<"The
Number in Yards is "<<y<<endl;
y=x/100000;
cout<<"The
Number in Km is "<<y<<endl;
y=x/160000;
cout<<"The
Number in Mile is "<<y<<endl;
getche ();
return 0;
}
Q3. Write a program that will take input currency in
Dollars and will convert in
Rupees
Ponds
Euro
Dinar
Riyal
Display
all these as output.
Program Code:
#include <iostream>
#include <conio.h>
using namespace std;
int main()
{float x,y;
cout<<"Enter
the currency in DOLLARS: ";
cin>>x;
y=x*102.12;
cout<<"The
currency in Rupees is "<<y<<endl;
y=x * 0.62;
cout<<"The
currency in Pound is "<<y<<endl;
y=x*0.78;
cout<<"The
currency in Euro is "<<y<<endl;
y=x * 1162;
cout<<"The
currency in Iraqi Dinar is "<<y<<endl;
y=x*3.75;
cout<<"The
currency in Saudi Riyal is "<<y<<endl;
getche ();
return 0;
}
Q6.
Write a program that will take your subject marks and will calculate your CGPA.
For this purpose you need to search
formula that will help you to calculate CGPA.
Program
Code:
#include <iostream>
#include <conio.h>
using namespace std;
int main()
{float x,y,z;
float cal,ap,wp,lca,isl,cf,bme,edc,ems,la,ode,cad;
cout<<"Enter
the grade in Calculus ";
cin>>cal;
cout<<"Enter
the grade in Applied Physics ";
cin>>ap;
cout<<"Enter
the grade in Workshop ";
cin>>wp;
cout<<"Enter
the grade in LCA ";
cin>>lca;
cout<<"Enter
the grade in Islamiat ";
cin>>isl;
cout<<"Enter
the grade in Computer Fundamentals ";
cin>>cf;
cout<<"Enter
the grade in BME ";
cin>>bme;
cout<<"Enter
the grade in EDC ";
cin>>edc;
cout<<"Enter
the grade in EMS ";
cin>>ems;
cout<<"Enter
the grade in LA ";
cin>>la;
cout<<"Enter
the grade in ODE ";
cin>>ode;
cout<<"Enter
the grade in CAD ";
cin>>cad;
y=(cf*3+isl*2+wp*2+ap*4+cal*3+lca*4)/18;
cout<<"The
Spga in 1st Semester is "<<y<<endl;
z=(bme*3+edc*4+ems*4+ode*3+la*3+cad*1)/18;
cout<<"The
Spga in 2nd Semester is "<<z<<endl;
x=(y+z)/2;
cout<<"The
Cgpa is "<<x<<endl;
getche
();
return 0;
}
Program for Calculator of arithmatic operation:
#include <iostream>
#include <conio.h>
using namespace std;
int main()
{char operation;
int a,b;
cout<<"Enter first Number: ";
cin>>a;
cout<<"Enter second Number: ";
cin>>b;
cout<<"Enter an operation arithmatic operation do you
want: ";
cin>>operation;
switch (operation)
{
case '+' :
cout<<"The Addition of numbers= "<<a+b;
break;
case '-':
cout<<" The Subtraction of numbers= "<<a-b;
break;
case '*':
cout<<"The Multiplication of numbers= "<<a*b;
break;
case '/':
cout<<"The Division of numbers= "<<a/b<<endl;
break;
}
getche
();
return 0;
}
Calculator
Using If-else Statement:
Program
Code;
#include <iostream>
#include <conio.h>
using namespace std;
int main()
{float x,y,z;
int operation;
cout<<"Enter
a Number:";
cin>>x;
cout<<"Enter
another Number:";
cin>>y;
cout<<"Enter
1 for Addition, 2 for Subtraction"<<endl<<" 3 for
Multiplication, 4 for Division ";
cin>>operation;
if (operation ==1)
{cout<<"The
Addition is "<<x+y<<endl;}
else
if(operation == 2)
{cout<<"The
Subtraction is "<<x-y<<endl;}
else
if(operation == 3)
{cout<<"The
Product is "<<x*y<<endl;}
else
{cout<<"The
Division is "<<x/y<<endl;}
getche ();
return 0;
}