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
Describe wild pointers in c?
Explain pointers in c programming?
Are global variables static in c?
What is the significance of c program algorithms?
How do I determine whether a character is numeric, alphabetic, and so on?
Explain what is the difference between a free-standing and a hosted environment?
What does *p++ do? What does it point to?
What is the right type to use for boolean values in c?
hai iam working in sap sd module for one year and working in lumax ind ltd in desp department but my problem is i have done m.b.a in hr/marketing and working sap sd there is any combination it. can you give right solution of my problem. and what can i do?
Explain the use of bit fieild.
When can a far pointer be used?
Explain heap and queue.
what is the height of tree if leaf node is at level 3. please explain
Explain what could possibly be the problem if a valid function name such as tolower() is being reported by the c compiler as undefined?
Does sprintf put null character?