BZU PAGES: Find Presentations, Reports, Student's Assignments and Daily Discussion; Bahauddin Zakariya University Multan

BZU PAGES: Find Presentations, Reports, Student's Assignments and Daily Discussion; Bahauddin Zakariya University Multan (http://bzupages.com/)
-   Object Oriented Programming (http://bzupages.com/300-object-oriented-programming/)
-   -   Program to enter two integers and find their sum and average (http://bzupages.com/f300/program-enter-two-integers-find-their-sum-average-14541/)

bonfire 28-02-2011 10:46 PM

Program to enter two integers and find their sum and average
 
1 Attachment(s)
Program to enter two integers and find their sum and average

#include
#include
#include

void main()
{
clrscr();
int x,y,sum;
float average;
cout << "Enter 2 integers : " << endl;
cin>>x>>y;
sum=x+y;
average=sum/2;
cout << "The sum of " << x << " and " << y << " is " << sum << "." << endl;
cout << "The average of " << x << " and " << y << " is " << average << "." << endl;
getch();
}
This program takes in two integers x and y as a screen input from the user.
The sum and average of these two integers are calculated and outputted using the 'cout' command.

Sample Input
8 6

Sample Output

The sum of 8 and 6 is 14.
The average of 8 and 6 is 7.



All times are GMT +5. The time now is 06:59 AM.

Powered by vBulletin® Version 3.8.2
Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.