Write a program to find the smallest and largest element in
a given array in c language
Answer Posted / anudeep
#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 ? | 3 Yes | 6 No |
Post New Answer View All Answers
What do mean by network ?
Write a program to check whether a number is prime or not using c?
To print the pattern 1 2 3 4 5 10 17 18 19 6 15 24 25 20 7 14 23 22 21 8 13 12 11 10 9
i want to know the procedure of qualcomm for getting a job through offcampus
Is there any demerits of using pointer?
Explain how do you declare an array that will hold more than 64kb of data?
Is there sort function in c?
What is volatile variable in c with example?
What is difference between constant pointer and constant variable?
What do you understand by friend-functions? How are they used?
Which is better between malloc and calloc?
Why do we use main function?
What is queue in c?
How can a number be converted to a string?
shorting algorithmS