Header Ads

C program for largest of n numbers

C program for largest of n numbers: -

We first input the numbers of number we want to input for checking largest  number among them after that it asks for the numbers serially we enter and hit enter too at last it show the result.

Program

#include<stdio.h>
#include<conio.h>
int main()
{
  int n;
  printf("Enter the values of n: ");
  scanf("%d",&n);
  void largest(int);
  largest(n);
  getch();
}
void largest(int n1)
{
 int big,num,i;
 printf("Number %d: ",1);
    scanf("%d",&big);
 for(i=2;i<=n1;i++)
 {
  
    printf("Number %d: ",i);
    scanf("%d",&num);

    if(big<num)
      big=num;
  }
 
  printf("Largest number is: %d",big);
}

Output

Enter the values of n: 5
Number 1: 9
Number 2: 26
Number 3: 12
Number 4: 8
Number 5: 14
Largest number is: 26_

No comments