Powered By Blogger

11 February 2017

Program to find sum and average of 2 variables...

INPUT=

#include <iostream>
using namespace std; 

int main(){
    int x,y,sum;
    float average;

    cout << "Enter 2 integers : " << endl;
    cin>>x>>y;
    sum=x+y;
    average=sum/2;
    cout << "SUM=" << x << " and " << y << " is " << sum <<             
    "." << endl;
    cout << "AVERAGE= " << x << " and " << y << " is " <<       
    average << "." << endl;
}

OUTPUT=

  Enter 2 integers :
   5 10
   SUM=15
   AVERAGE=7.5

No comments:

Post a Comment