-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathProgram_35.c
More file actions
31 lines (29 loc) · 734 Bytes
/
Copy pathProgram_35.c
File metadata and controls
31 lines (29 loc) · 734 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
// Program 35: Write a program to find the maximum and minimum elements in an array.
#include<stdio.h>
int main(){
int n;
printf("Enter the number of terms : ");
scanf("%d",&n);
int arr[n];
for(int i=0;i<n;i++){
printf("Enter the element at index %d : ",i);
scanf("%d",&arr[i]);
}
for(int i=0;i<n;i++){
printf("%d\t",arr[i]);
}
printf("\n");
int max = arr[0] , min =arr[0];
for(int i = 0;i<n;i++){
if(max<arr[i]){
max=arr[i];
}
}
for(int i = 0;i<n;i++){
if(min>arr[i]){
min=arr[i];
}
}
printf("The maximum and minimum Terms in the array id %d and %d repectively . ",max,min);
return 0;
}