Write a program to find the smallest and largest element in
a given array in c language

Answer Posted / anudeep

#include <stdio.h>
#include <conio.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);
getch();
}

Is This Answer Correct ?    3 Yes 2 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

Hai,I have done with my bachelor of commerce and planing to ms,please suggest me how to convince vo for shifting from commerce to computers. Visa on 8 DEC 2014  Npu university

1605


Can we use visual studio for c?

556


PLS U SENS ME INTERVIEW O. MY EMAIL ADD, SOFIYA.SINGH@GMAIL.COM

1720


What is a stream water?

663


What are dangling pointers in c?

650






What's the best way of making my program efficient?

631


what do you mean by inline function in C?

620


Describe static function with its usage?

616


What is the use of header files?

612


How do you convert a decimal number to its hexa-decimal equivalent.Give a C code to do the same

655


What is fflush() function?

649


Is fortran still used today?

609


What is pragma in c?

636


How are Structure passing and returning implemented by the complier?

719


what are non standard function in c

1441