by Dinesh Thakur Category: C Programming (Pratical)

In this program user ask to find the Maximum number between the 5 numbers. Here user declares the variables that which store the value. User asks to enter the five numbers for compilation. Here user uses for loop to vary the condition regarding to situation. Here user declare nested loop statement for number and then if condition. If (a[i]>a[j]) if all the condition got vary then the loop statement will collaborate the number that it varies and put on the screen as result it has.

Problem Statement:

This is C program that asks user to find the bigger number from the 5 numbers.

  1. Declaring the variable.
  2. Using loop statement.
  3. Vary control statement.
  4. Display result on the screen.

Here is C source code for finding the maximum number from five No. The output of this program shown below. 

#include<stdio.h>

void main()
{
       int a[5],i,j,c;
       clrscr();
       printf("Enter five no. :");
       for(i=0;i<=4;i++)
           {
              scanf("%d",&a[i]);
           }
              for(i=0;i<=4;i++)
                  {
                     for(j=i+1;j<=4;j++)
                         {
                            if(a[i]>a[j])
                              {
                                  c=a[i];
                                  a[i]=a[j];
                                  a[j]=c;
                              }
                         }
                   }
                       for(i=0;i<=4;i++)
                           {
                                printf("%d",a[i]);
                           }
                                printf("\n");
                                getch();

Maximum Number Between 5 No

About Dinesh Thakur

Dinesh ThakurDinesh Thakur holds an B.SC (Computer Science), MCSE, MCDBA, CCNA, CCNP, A+, SCJP certifications. Dinesh authors the hugely popular blog. Where he writes how-to guides around Computer fundamental , computer software, Computer programming, and web apps. For any type of query or something that you think is missing, please feel free to Contact us.



Search Content