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
Why enum is used in c?
What is time null in c?
Using functions, write a program that multiplies two arrays. Use the following functions: - Function ReadArray - Function MultiplyArrays - Function DisplayArrays
What is logical error?
explain what are actual arguments?
What are c identifiers?
How many keywords (reserve words) are in c?
Difference between linking and loading?
any limit on the number of functions that might be present in a C program a) max 35 functions b) max 50 functions c) no limit d) none of the above
Explain how do you view the path?
Explain what is the heap?
Do you know the use of fflush() function?
How is actual parameter different from the formal parameter?
What was noalias and what ever happened to it?
Write a Program to find whether the given number or string is palindrome.