/*a program that inputs three integers from the
keyboard and prints the sum, average, product,
smallest and largest of these numbers*/
#include <iostream>
using namespace std;
int main()
{
int firstNum, secondNum, thirdNum, sum, product,average, largest, smallest;
cout<<"Enter three integers: ";
cin>>firstNum;
cin>>secondNum;
cin>>thirdNum;
sum = firstNum+secondNum+thirdNum;
product = firstNum*secondNum*thirdNum;
average = product/3;
cout<<"Sum is "<<sum <<"\n";
cout<<"Product is "<<product <<"\n";
cout<<"Average is "<<average <<"\n";
//code for finding the largest number
if(firstNum>secondNum)
{
if(firstNum>thirdNum)
{
cout<<"Largest is "<<firstNum<<"\n";
}
else if(thirdNum>firstNum)
{
cout<<"Largest is "<<thirdNum<<"\n";
}
else if(thirdNum==firstNum)
{
cout<<"Largest are "<<firstNum<<" and "<<thirdNum<<"\n";
}
}
else if(secondNum>thirdNum)
{
if(secondNum>firstNum)
{
cout<<"Largest is "<<secondNum<<"\n";
}
if(secondNum==firstNum)
{
cout<<"Largest are "<<firstNum<<" and "<<secondNum<<"\n";
}
}
else if(thirdNum>firstNum)
{
if(secondNum==thirdNum)
{
cout<<"Largest are "<<secondNum<<" and "<<thirdNum<<"\n";
}
else
{
cout<<"Largest is "<<thirdNum<<"\n";
}
}
else if(firstNum==secondNum && secondNum==thirdNum)
{
{
cout<<"All are equal.\n";
}
}
//end of the code for largest number
//**************************
//code for finding the smallest number
if(firstNum<secondNum)
{
if(firstNum<thirdNum)
{
cout<<"Smallest is "<<firstNum<<"\n";
}
else if(thirdNum<firstNum)
{
cout<<"Smallest is "<<thirdNum<<"\n";
}
else if(thirdNum==firstNum)
{
cout<<"Smallest are "<<firstNum<<" and "<<thirdNum<<"\n";
}
}
else if(secondNum<thirdNum)
{
if(secondNum<firstNum)
{
cout<<"Smallest is "<<secondNum<<"\n";
}
if(secondNum==firstNum)
{
cout<<"Smallest are "<<firstNum<<" and "<<secondNum<<"\n";
}
}
else if(thirdNum<firstNum)
{
if(secondNum==thirdNum)
{
cout<<"Smallest are "<<secondNum<<" and "<<thirdNum<<"\n";
}
else
{
cout<<"Smallest is "<<thirdNum<<"\n";
}
}
else if(firstNum==secondNum && secondNum==thirdNum)
{
{
cout<<"All are equal.\n";
}
}
//end of the code for finding the smallest number
cout<<"\n\nPress any key and ENTER to EXIT";
char response;
cin>> response;
return 0;
}
csha_cs508 0 Newbie Poster
jonsca 1,059 Quantitative Phrenologist Team Colleague Featured Poster
csha_cs508 0 Newbie Poster
jonsca 1,059 Quantitative Phrenologist Team Colleague Featured Poster
csha_cs508 0 Newbie Poster
jonsca 1,059 Quantitative Phrenologist Team Colleague Featured Poster
csha_cs508 0 Newbie Poster
Be a part of the DaniWeb community
We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.