IN C++ PLEASE CODE THE FOLLOWING Given int item1, item2, item3, avevalue; item1
ID: 3733591 • Letter: I
Question
IN C++ PLEASE CODE THE FOLLOWING
Given
int item1, item2, item3, avevalue;
item1 = 90;
item2 = 67;
item3 = 72;
avevalue = 0;
Write a program to perform the following tasks.
I. declare and initialize item1, item2, item3 and avevalue as above.
II. compute the average value – avevalue on item1, item2, and item3, and then display
avevalue on the screen.
III. define int max(int a, int b, int c) to return the maximum value among the three input arguments.
IV. using max() to find out the maximum value among item1, item2, and item3, return the maximum
value, and then display it on the screen.
Explanation / Answer
#include <iostream>
using namespace std;
int main()
{
int item1=90;//Here We Initialized The Variables
int item2=67;
int item3=72;
int avaragevalue=0;
int avgvalue=item1+item2+item3/3;
cout<<"Total Avarage Value = " << avgvalue; //This Is The Total Avarage Value
//Now Avarage Value On Perticular Item
avgvalue=item1+item2+item3/item1;
avgvalue=item1+item2+item3/item2;
avgvalue=item1+item2+item3/item3;
cout<<"Total Avarage Value On Item 1= " << avgvalue; //Avarage Value On Item1
cout<<"Total Avarage Value On Item 2= " << avgvalue; //Avarage Value On Item2
cout<<"Total Avarage Value On Item 3= " << avgvalue; //Avarage Value On Item3
if(item1 >= item2 && item1 >= item3)
{
cout << "Largest number: " << item1;
}
if(item2 >= item1 && item2 >= item3)
{
cout << "Largest number: " << item2;
}
if(item3 >= item1 && item3 >= item2) {
cout << "Largest number: " << item3;
}
}
I Have Done This Please Check