Write a program to find the smallest and largest element in
a given array in c language
Answer Posted / alive
#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 ? | 15 Yes | 13 No |
Post New Answer View All Answers
Explain about the functions strcat() and strcmp()?
What is LINKED LIST? How can you access the last element in a linked list?
The difference between printf and fprintf is ?
What is main () in c language?
disply the following menu 1.Disply 2.Copy 3.Append; as per the menu do the file operations 4.Exit
Why dont c comments nest?
What is the size of enum in bytes?
What is conio h in c?
Difference between goto, long jmp() and setjmp()?
In a switch statement, what will happen if a break statement is omitted?
Why & is used in c?
What is modeling?
Is using exit() the same as using return?
Can a pointer point to null?
How many parameters should a function have?