-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathbinary.c
More file actions
46 lines (40 loc) · 1.08 KB
/
Copy pathbinary.c
File metadata and controls
46 lines (40 loc) · 1.08 KB
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
/*-------------------------------------------------------------------------------------------------------------------------------
BubbleSort.c
Program to sort n numbers in ascending order using bubble sort.
DIVYA RAJ K
25-09-2018
---------------------------------------------------------------------------------------------------------------------------------*/
#include<stdio.h>
#include<math.h>
main()
{
int X[30],N,i,Max,Min,MaxLoc,MinLoc;
system("clear");
printf("Program to find the maximum and minimum number in an array and also find its location\n\n");
printf("Enter the number of elements: ");
scanf("%d",&N);
printf("Enter %d numbers:\n",N);
for(i=1;i<=N;i++){
scanf("%d",&X[i]);
}
Max=X[1];
Min=X[1];
MaxLoc=1;
MinLoc=1;
for(i=2;i<=N;i++){
if(X[i]>Max){
Max=X[i];
MaxLoc=i;
}
if(X[i]<Min){
Min=X[i];
MinLoc=i;
}
}
printf("\nThe entered numbers are:\n");
for(i=1;i<=N;i++){
printf("%d\t",X[i]);
}
printf("\n\nThe maximum number is %d and location is %d",Max,MaxLoc);
printf("\n\nThe minimum number is %d and location is %d",Min,MinLoc);
}