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


Please Help Members By Posting Answers For Below Questions

Explain what is the difference between the expression '++a' and 'a++'?

628


What is action and transformation in spark?

598


What is the difference between mpi and openmp?

737


What does c mean in standard form?

600


What are the different types of C instructions?

679






Do pointers store the address of value or the actual value of a variable?

612


What is the benefit of using an enum rather than a #define constant?

662


a sequence of bytes with one to one corrspondence to those in the external device a) sequential addressing b) address c) byte code d) none

726


What is structure packing in c?

609


What is a structural principle?

641


What is the value of a[3] if integer a[] = {5,4,3,2,1}?

674


Write a program to generate the Fibinocci Series

668


how to execute a program using if else condition and the output should enter number and the number is odd only...

1660


What is an auto keyword in c?

644


How many keywords are there in c?

592