Syvum Home Page

Home > Quiz Games > C++ Programming > Print Preview

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.
The sum and average of these two integers are calculated and outputted using the 'cout' command.

8 6

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

Index of C++ Programs
 

-
-
 
45 more pages in C++ Programming

Contact Info © 1999-2024 Syvum Technologies Inc. Privacy Policy Disclaimer and Copyright