C++ Programming : Program 3-A
Program to enter two integers and find their sum and average
#include <iostream.h> #include <iostream.h> #include <conio.h> 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.
8 6
The sum of 8 and 6 is 14. The average of 8 and 6 is 7.
|
45 more pages in C++ Programming