/* find the min and max value with these locations*/
#include<stdio.h>
#include<conio.h>
void main()
{
int a[20],i, n,max,min,min_pos,max_pos;
clrscr();
printf("Enter the Limit:");
scanf("%d",&n);
if(n<=20)
{
printf("Enter The No for Array:");
for(i=0;i<n;i++)
scanf("%d",&a[i]);
max=a[0];
min=a[0];
for(i=0;i<n;i++)
{
if(a[i]>=max)
{
max=a[i];
max_pos=i+1;
}
if(a[i]<=min)
{
min=a[i];
min_pos=i+1;
}
}
printf("\nThe Bigest number in array is %d at %d",max,max_pos);
printf("\nThe Smallest number in array is %d at %d",min,mix_pos);
}
else
printf("Enter the value of less than or equal to 20");
getch();
}
#include<stdio.h>
#include<conio.h>
void main()
{
int a[20],i, n,max,min,min_pos,max_pos;
clrscr();
printf("Enter the Limit:");
scanf("%d",&n);
if(n<=20)
{
printf("Enter The No for Array:");
for(i=0;i<n;i++)
scanf("%d",&a[i]);
max=a[0];
min=a[0];
for(i=0;i<n;i++)
{
if(a[i]>=max)
{
max=a[i];
max_pos=i+1;
}
if(a[i]<=min)
{
min=a[i];
min_pos=i+1;
}
}
printf("\nThe Bigest number in array is %d at %d",max,max_pos);
printf("\nThe Smallest number in array is %d at %d",min,mix_pos);
}
else
printf("Enter the value of less than or equal to 20");
getch();
}
No comments:
Post a Comment