Q : Write a program to input a set of numbers into an array. Pass the array to a function that finds and display the largest number.?
Answer :
#include<stdio.h>
#include<conio.h>
/*============================
Girfa Student Help
Find largest no. in array using function
==============================*/
void find(int ar[5]);
void main()
{
int ar[5],i;
clrscr();
for(i=0;i<5;i++)
{
printf("Enter
Number>> ");
scanf("%d",&ar[i]);
}
find(ar);
getch();
}
void find(int ar[5])
{
int i,j;
j=ar[0];
for(i=1;i<5;i++)
{
if(j<ar[i])
j=ar[i];
}
printf("\nLargest
No. is %d",j);
}
No comments:
Post a Comment