Write a program that takes four floating numbers from the keyboard and prints their sum, product, and average.
Code:
#include<iostream>
#include<conio.h>
using namespace std;
void main()
{
float n1,n2,n3,n4,sum,pro,avg;
cout<<“Please Enter Any Four Numbers.\n\n”;
cin>>n1>>n2>>n3>>n4;
sum= n1+n2+n3+n4;
pro= n1*n2*n3*n4;
avg= (n1+n2+n3+n4)/4;
cout<<“\nAddition of Four Number is: “<<sum<<endl;
cout<<“Product of Four Number is : “<<pro<<endl;
cout<<“Avg of Four Number is : “<<avg<<endl;
getch();
}
#include<iostream> #include<conio.h> using namespace std; void main() { float n1,n2,n3,n4,sum,pro,avg; cout<<"Please Enter Any Four Numbers.\n\n"; cin>>n1>>n2>>n3>>n4; sum= n1+n2+n3+n4; pro= n1*n2*n3*n4; avg= (n1+n2+n3+n4)/4; cout<<"\nAddition of Four Number is: "<<sum<<endl; cout<<"Product of Four Number is : "<<pro<<endl; cout<<"Avg of Four Number is : "<<avg<<endl; getch(); }
Output: