C Program to find largest and smallest value in an array - c programs
//C Program to find largest and smallest value in an array
#include <stdio.h>
#include <conio.h>
main()
{
int a[20];
int c,y,big,low;
clrscr();
printf("enter no of elements of array");
scanf("%d",&y);
printf("enter %d values", y)
for(c=0;c<y;c++)
{
printf("%d\t",a[c]);
big=0;
for(c=0;c<y;c++)
{
if(a[c]>big)
big=a[c];
if(a[c]<big)
low=a[c];
}
printf("\n the biggest value is %d", big);
printf("\n the smallest value is %d", low);
getch();
}
#include <conio.h>
main()
{
int a[20];
int c,y,big,low;
clrscr();
printf("enter no of elements of array");
scanf("%d",&y);
printf("enter %d values", y)
for(c=0;c<y;c++)
{
printf("%d\t",a[c]);
big=0;
for(c=0;c<y;c++)
{
if(a[c]>big)
big=a[c];
if(a[c]<big)
low=a[c];
}
printf("\n the biggest value is %d", big);
printf("\n the smallest value is %d", low);
getch();
}
No comments:
Post a Comment