7. Program that inputs a series of 20 numbers and displays the minimum value.

Chapter 6: 

Looping Structures

Programming Exercise

Problem # 7:

Write a program that inputs a series of 20 numbers and displays the minimum value.

Solution:

#include<iostream>
#include<conio.h>
using namespace std;
int main()
{
    int num, min;
    cout<<"Enter a number:";
    cin>>num;
    min=num;
    for(int n=1;n<=19;n++)
    {
        cout<<endl<<"Enter a number:";
        cin>>num;
        if(num<min)
            min=num;
    }
    cout<<endl<<"The minimum nuber is:"<<min;
    return 0;
}

Let me know in the comment section if you have any question.

Previous Post:
6. Program that will ask the user a question with four possible answers. The program should output the number of times each answer was selected.

Comments

Post a Comment