0 votes
397 views
in C programming by (98.9k points)
edited
Write a program to find the largest of n numbers taken from user, using a function the array of numbers must be passed to the function. The largest number must be found in the function and returned to the main function.

1 Answer

0 votes
by (98.9k points)
selected by
 
Best answer
#include<stdio.h>
#include<conio.h>
void main()
{
int n,i,a[100],large;
int largest (int a[], int n);
clrscr();
printf("Enter the number of elements:");
scanf("%d",&n);
for(i=0;i<=n-1;i++)
{
printf("Enter a value:");
scanf("%d",&a[i]);
}
large=largest(a,n);
printf("The largest number is %d",large);
getch();
}
int largest (int a[], int n)
{
int i,large;
large=a[0];
for(i=1;i<=n-1;i++)
{
if(large<a[i])
large=a[i];
}
return large;
}

 

Related questions

0 votes
1 answer 118 views
0 votes
1 answer 197 views
0 votes
1 answer 327 views

Doubtly is an online community for engineering students, offering:

  • Free viva questions PDFs
  • Previous year question papers (PYQs)
  • Academic doubt solutions
  • Expert-guided solutions

Get the pro version for free by logging in!

5.7k questions

5.1k answers

108 comments

557 users

...