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 difference between main and void main?
What is pointer in c?
What does sizeof return c?
What oops means?
Can you apply link and association interchangeably?
What does malloc () calloc () realloc () free () do?
What is the equivalent code of the following statement in WHILE LOOP format?
Explain how can you restore a redirected standard stream?
Where are c variables stored in memory?
When should you not use a type cast?
What is identifiers in c with examples?
What is the difference between char array and char pointer?
How can I find out the size of a file, prior to reading it in?
what is the difference between north western polytechnique university and your applied colleges?? please give ur answers for this. :)
How can I write a function analogous to scanf?