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
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
Can we use visual studio for c?
PLS U SENS ME INTERVIEW O. MY EMAIL ADD, SOFIYA.SINGH@GMAIL.COM
What is a stream water?
What are dangling pointers in c?
What's the best way of making my program efficient?
what do you mean by inline function in C?
Describe static function with its usage?
What is the use of header files?
How do you convert a decimal number to its hexa-decimal equivalent.Give a C code to do the same
What is fflush() function?
Is fortran still used today?
What is pragma in c?
How are Structure passing and returning implemented by the complier?
what are non standard function in c