forked from srinirad/Test3Session2
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathp5final.c
More file actions
47 lines (47 loc) · 743 Bytes
/
p5final.c
File metadata and controls
47 lines (47 loc) · 743 Bytes
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
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
#include<stdio.h>
int input_size()
{
int n;
printf("enter the size of the array: ");
scanf("%d",&n);
return n;
}
void input_array(int n,int a[n])
{
int i;
printf("enter the array elements: \n");
for(i=0;i<n;i++)
{
scanf("%d",&a[i]);
}
}
int find_largest(int n,int a[n])
{
int i,big=0,largest;
for(i=0;i<n;i++)
{
if (a[i]>big)
{
big=a[i];
largest=i;
}
else
{
big=big;
}
}
return largest;
}
void output(int n,int a[n],int largest)
{
printf("the index of the largest number in an array is %d",largest);
}
void main()
{
int n,biggest;
n=input_size();
int a[n];
input_array(n,a);
biggest=find_largest(n,a);
output(n,a,biggest);
}