**Simple c++ program which takes input numbers from user and find minimum, maximum and average of numbers**. Program uses do while loop to find min, max and avg. User can input many numbers. To calculate user has to break do while loop condition which breaks when user inputs -1.

#include<iostream> #include<conio.h> using namespace std; int main() { float max=0.0,min=0.0,sum=0.0; float num=0.0; float avg=0.0; cout<<"enter a whole number or -1 to get result:"; //program working through example cin>>num; max=num; min=num; do { if(num!=-1){ sum=sum+num; if(num>max) max=num; else if(num<min) min=num; cout<<"enter a whole number or -1 to get result:"; cin>>num; } } while(num!=-1); avg=sum/10.0; cout<<"sum="<<sum<<endl; cout<<"average of numbers you entered is:"<<avg<<endl; cout<<"maximum number you enter is:"<<max<<endl; cout<<"minimum number you enter is:"<<min<<endl; getch(); }

program output:

find more examples here: c++ programming examples and solutions

find sample c++ projects here: c++ projects source codes

## 0 comments:

## Post a Comment