Write a program to obtain average of two numbers.

Here the compile reads two inputs at the run time and perform the average. Its a simple logic to perform average of two numbers.

#include <iostream.h>
int main()
{
float number1, number2,
sum,average;
cout << "Enter two number: ";
cin >> number1;
cin >> number2;
sum = number1 + number2;
average = sum/2;
cout << "Sum =" << sum <<"\n";
cout << "Average =" << average <<"\n";
return 0;
}

Output:

Enter two numbers: 6.5 7.5
Sum = 14
Average = 7

0 comments:

Post a Comment

 

About Me

It's Me!Hi, I'm Moinuddin. I'm a Software Engineer at WIPRO working on Microsoft .NET Technology. I'm interested in a wide range of technology topics, mainly Microsoft including Windows Azure, WCF, WPF, Silverlight and any other cool technology that catches the eye.

Site Info

ProjectCSharp.com is mainly about demonstrating real time examples in different technologies like ASP.NET, WCF, WPF, Silverlight, Azure etc..,

Followers

Help Links

Project CSharp (C#) Copyright © 2011. All Rights Reserved.