Write a program to find the smallest and largest element in
a given array in c language
Answer Posted / dinesh
#include <stdio.h>
int main()
{
int a[20],min,max;
int n,i;
printf("enter the num of elements\t:");
scanf("%d",&n);
printf("enter the elements\n");
for( i=0;i<n;i++)
{
scanf("%d",&a[i]);
if(i==0)
{
min=max=a[i];
}
if(a[i]<min)
min=a[i];
else if(a[i]>max)
max=a[i];
}
printf("Biggest element is %d and Smallest element
is %d ",max,min);
}
| Is This Answer Correct ? | 11 Yes | 9 No |
Post New Answer View All Answers
What is hash table in c?
What is operator promotion?
Why void is used in c?
how to execute a program using if else condition and the output should enter number and the number is odd only...
Are there any problems with performing mathematical operations on different variable types?
What is return in c programming?
Is null always defined as 0(zero)?
When a c file is executed there are many files that are automatically opened what are they files?
Do array subscripts always start with zero?
What is null in c?
what is event driven software and what is procedural driven software?
How old is c programming language?
What does volatile do?
How main function is called in c?
What is meant by 'bit masking'?