Write a program using any programming language that reads five numbers from keyboard and display the smaller,larger and average of those numbers.

Bank, Interview Programming, JOB Exam

Bangladesh Development Bank

Senior Officer (IT)

Written Test – 2017

#include <iostream>
#include<stdio.h>

using namespace std;

int main()
{
    int i,n,max,min,total,sum;
    float avg;
    printf("Enter Total number of elements \n");
    cin>>total;
    cout<<"Enter number \n";
    cin>>n;
    max=n;
    min=n;
    sum=n;
    for(i=1;i<=total-1;i++)
    {
        cin>>n;
        if(n>max)
        max=n;
        else if(n<min)
        min=n;
        sum+=n;
    }
    printf("\n The largest number is %d",max);
    printf("\n The smallest number is %d",min);
    printf("\n The average number is %f",avg=(sum/total));
    return 0;
    
}

Enter Total number of elements

4

Enter numbers

22,33,23,31

The largest number is 33

The smallest number is 223

The avg number is 27.000000

0 Comments

You may find interest following article