find greatest number among array in c

Solutions on MaxInterview for find greatest number among array in c by the best coders in the world

showing results for - "find greatest number among array in c"
Caterina
27 Sep 2017
1#include <stdio.h>
2void main()
3{
4    int a[100],b[100],s[100];
5    int i,j;
6    int n,temp;
7
8    printf("How many numbers do you want to input? : ");
9    scanf("%d",&n);
10
11    for(i=0;i<n;i++)
12    {
13        printf("Enter %d number of first list : ",i+1);
14        scanf("%d",&a[i]);
15    }
16
17    printf("\n\n");
18
19    for(i=0;i<n;i++)
20    {
21        printf("Enter %d number of second list : ",i+1);
22        scanf("%d",&b[i]);
23
24    }
25
26    for(i=0;i<n;i++)
27    {
28
29        s[i] = a[i] + b[i];
30    }
31
32    printf("\n\n....... the sum of arrays........\n\n");
33
34
35    for(i=0;i<n;i++)
36    {
37         printf("%d ",s[i]);
38    }
39
40
41    printf("\n\n...... arranging the sum in ascending order...\n\n");
42
43    for (i = 0; i < n; ++i)
44    {
45
46        for (j = i + 1; j < n; ++j)
47        {
48            if (s[i] > s[j])
49
50            {
51                temp =  s[i];
52                s[i] = s[j];
53                s[j] = temp;
54            }
55        }
56    }
57
58    for (i=0;i<n;i++)
59    {
60        printf("%d ",s[i]);
61    }
62
63    getch();
64}
65