Thursday, 13 October 2016

HHW Q7. WAP to find an average of 5 nos. entered by user and print the nos. larger than avg. no.

#include<iostream.h>
#include<conio.h>
void main()
{
clrscr();
int a,b,c,d,e,f,g;
cout<<"Enter 5 nos. ";
cin>>a>>b>>c>>d>>e;
f=(a+b+c+d+e)/5;
cout<<"Average of these nos. = "<<f<<"\n";
if (a>f){cout<<a<<" is greater than average no."<<"\n";}
if (b>f){cout<<b<<" is greater than average no."<<"\n";}
if (c>f){cout<<c<<" is greater than average no."<<"\n";}
if (d>f){cout<<d<<" is greater than average no."<<"\n";}
if (e>f){cout<<e<<" is greater than average no."<<"\n";}
getch();
}

No comments:

Post a Comment

Basic Implementation of Array as a Pointer

#include<iostream.h> #include<conio.h> void main() { clrscr();   int arr[5];   cout<<"Enter 5 nos. ";   f...