a) const double Pi=3.14;
b) double Parameter;
c)cout<<"input data";
cin>>data;
d) int num_compt;
cout<<"input number of computer";
cin>>num_compt;
Monday, February 28, 2011
Exercises No 3
main()
{
float Allowance=300.00;
float salary;
cout<<"Input Salary=";
cin>>salary;
Tsalary=salary+ Allowance;
cout>>"Salary is=" , salary;
}
{
float Allowance=300.00;
float salary;
cout<<"Input Salary=";
cin>>salary;
Tsalary=salary+ Allowance;
cout>>"Salary is=" , salary;
}
Exercises No 4
#include <
main()
{
double day_salary;
int days=20;
double monthly_salary;
cout<<"enter day salary";
cin>>day_salary;
cout<<"enter days working";
cin>>days;
monthly_salary=Day_salary*days;
cout<<"Your monthly salary =", monthly_salary;
}
Exercises No 5
Program that calculates the average of 5 numbers that can be input by user.
#include <iostream.h>
main()
{
int num1, num2, num3, num4, num5, average;
cout<<"enter number 1";
cin>>num1;
cout<<"enter number 2";
cin>>num2;
cout<<"enter number 3";
cin>>num3;
cout<<"enter number 4";
cin>>num4;
cout<<"enter number 5";
cin>>num5;
average=(num1+num2+num3+num4+num5)/5;
cout<<"average for five number is=" , average;
}
#include <iostream.h>
main()
{
int num1, num2, num3, num4, num5, average;
cout<<"enter number 1";
cin>>num1;
cout<<"enter number 2";
cin>>num2;
cout<<"enter number 3";
cin>>num3;
cout<<"enter number 4";
cin>>num4;
cout<<"enter number 5";
cin>>num5;
average=(num1+num2+num3+num4+num5)/5;
cout<<"average for five number is=" , average;
}
Exercises no 6
Program that will calculate the area of rectangular, triangle and circle.
#include <iostream.h>
main()
{
double area_rect , area_triangle, area_circle, base , height, width, radius;
const double π=3.14;
cout<<"Calculate area of rectangular.";
cout<<"Enter height=";
cin>>height;
cout<<"Enter width";
cin>>width;
area_rect=height * width;
cout<<"area of rectangular=", area_rect;
cout<<"Calculate area of triangle.";
cout<<"Enter base=";
cin>>base;
cout<<"Enter height";
cin>>height;
area_triangle= 1/2 * base * height ;
cout<<"area of triangle=", area_triangle;
cout<<"Calculate area of circle.";
cout<<"Enter radius=";
cin>>radius;
area_circle= 3.14;
cout<<"area of circle=", area_circle;
}
#include <iostream.h>
main()
{
double area_rect , area_triangle, area_circle, base , height, width, radius;
const double π=3.14;
cout<<"Calculate area of rectangular.";
cout<<"Enter height=";
cin>>height;
cout<<"Enter width";
cin>>width;
area_rect=height * width;
cout<<"area of rectangular=", area_rect;
cout<<"Calculate area of triangle.";
cout<<"Enter base=";
cin>>base;
cout<<"Enter height";
cin>>height;
area_triangle= 1/2 * base * height ;
cout<<"area of triangle=", area_triangle;
cout<<"Calculate area of circle.";
cout<<"Enter radius=";
cin>>radius;
area_circle= 3.14;
cout<<"area of circle=", area_circle;
}
Subscribe to:
Posts (Atom)