Average of two number in c++ program

 Average of two number in c++ program

#include<iostream>
using namespace std;
int main()
{
    float num1,num2,sum,average;
    cout<<"\n"<<"enter first number:";
    cin>>num1;
    cout<<"\n"<<"enter second number:";
    cin>>num2;
    sum=num1+num2;
    average=sum/2;
    cout<<"sum="<<sum<<"\n";
    cout<<"average="<<average<<"\n";
return 0;   
}

output--- Enter the first number:12

 Enter the second number:21

sum=33

average=16.5

 


 


important program of c---
   A certain grade of steel is graded according to following condition: (i) Hardness must be greater than 50. (ii)carbon content must be less than 0.7 (iii)Tensile strength must be greater than 5600. the grades as follows: grade is 10 if all three condition are met, Grade is 9 if conditions (i)and (ii) are met , Grade is 8 if condition (ii) and (iii) are met , Grade is 7 if condition (i) and (iii) are met, Grade is 6 if only one condition is met , Grade is 5 if none of the conditions are met . write a program which will require the user to give values of hardness , carbon content and tensile strength of the steel under consideration and output the grade of steel

more program visit my website---https://allcodescience.blogspot.com/ 

 

Comments

Popular posts from this blog

If lengths of three sides of a tringle are input through the keyboard write a program to find the area of tringle.

the length and breadth of a rectangle and radius of a circle are input through the keyboard. write a program to calculate the area and perimeter of the rectangle, and the area and circumference of the circle

paper of size A0 has dimensions 1189 mmx 841 mm .Each subsequent size A(n) is defined as A(n-1) cut in half parallel to its shorter sides .Thus paper of size A1 would have dimensions 841 mm X 594 mm .Write a program to calculate the print paper sizes A0,A1,A2,.........A8.