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

class with array in c++ (memory allocatin & using array in classes)

constructor with default arguments

constructor overloading in c++ programming