Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 13 additions & 0 deletions C/program-47/Readme.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
Program 47

Write a program to find the maximum and minimum element in an array.

Variable description--

n=Number of elements in an array

a=Array of size N

min= Holds the minimum element

max=Holds the maximum element
23 changes: 23 additions & 0 deletions C/program-47/program.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
#include <stdio.h>
int main()
{

int a[100],n,min,max;
printf("enter the size of the array");
scanf("%d",&n);
printf("enter the elements of the array");
for(int i=0;i<n;++i)
scanf("%d",&a[i]);
//Assuming the first element of the array to be minimum and maximum
min=a[0];
max=a[0];
for(int i=1;i<n;++i)
{
if(a[i]>max)
max=a[i];
if(a[i]<min)
min=a[i];
}
printf("The minimum element is %d\n",min);
printf("The maximum element is %d",max);
}