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(); } 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.