Program to accept ten numbers from the user and display the largest one

This program accepts ten numbers from the user and displays the largest one,

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
#include "conio.h"
#include "stdio.h"
 
void main()
{
  int num[10],grt,i=0,j=1;
  printf("\nPlease provide 10 numbers to find largest one ");
  for(;i<10;i++,j++)
  {
  printf("\nEnter number %d : ",j);
  scanf("%d",&num[i]);
  }
  grt=num[0];
  i=0,j=1;
//finding largest number
  for(;i<9;i++)
  {
    if(grt<num[i+1])
    {
    grt=num[i+1];
    }
  }
//displaying largest value
  printf("\nThe largest number is : %d",grt);
getch();
}

Output:

Please provide 10 numbers to find largest one
Enter number 1 : 41
Enter number 2 : 75
Enter number 3 : 76
Enter number 4 : 40
Enter number 5 : 55
Enter number 6 : 59
Enter number 7 : 48
Enter number 8 : 54
Enter number 9 : 71
Enter number 10 : 48
The largest number is : 76
Chitra
Chitra

Leave a Reply

Your email address will not be published. Required fields are marked *

Get the latest updates on your inbox

Be the first to receive the latest updates from Codesdoc by signing up to our email subscription.

    StudentProjects.in