Write a c++ program to find sum and average of two numbers.

Write a c++ program to find sum  and average of two numbers.
This question always asked in Technical Interview.




#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 << "sum="<< sum << "." << endl;
cout << "average=" << average << "." << endl;

getch();

}


SAMPLE INPUT:
Enter 2 integers :
8 6

SAMPLE OUTPUT:
sum=14.
average=7.






No comments:

Post a Comment

We are here to listen you, Comment your valueable opinion...!!!