Langsung ke konten utama

Simple Program to Find Max, Mid, and Min from 3 Number in C programming language

 


If you search the source code for this program, here is the example.

#include<stdio.h>
#include<conio.h>
/*this is the example of program,
how to get the mid, min and max from 3 number*/
void main()
{
    int num0=0,num1=0,num2=0;
     int max,min,mid;
     //to input the number
     clrscr();
     printf(“————————————-PROGRAM————————————\n”);
     printf(” Input Number-1 = “); scanf(“%d”,&num0);
     printf(” Input Number-2 = “); scanf(“%d”,&num1);
     printf(” Input Number-3 = “); scanf(“%d”,&num2);

    //this is the proccess
     if((num2 >= num1) && (num2 >= num0)){
         max = num2;
         if(num1 >= num0){
             mid = num1;
             min = num0;}
         else{
             mid = num0;
             min = num1;}
      }
     else if((num1 >= num2) && (num1 >= num0)){
         max = num1;
         if(num2 >= num0){
             mid = num2;
             min = num0;}
         else{
             mid = num0;
             min = num2;}
     }
     else if((num0 >= num2) && (num0 >= num2)){
         max = num0;
         if(num2 >=num1){
             mid = num2;
             min = num1;}
         else{
             mid = num1;
             min = num2;}
         }
//to show the result
    printf(“\n======================================RESULT====================================\n”);
    printf(” Maximum = %d\n”,max);
    printf(” Middle = %d\n”,mid);
    printf(” Minimum = %d\n”,min);
    printf(“\n—————————————-END————————————-“);

    getch();
}