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
Explain what is the difference between the expression '++a' and 'a++'?
What is action and transformation in spark?
What is the difference between mpi and openmp?
What does c mean in standard form?
What are the different types of C instructions?
Do pointers store the address of value or the actual value of a variable?
What is the benefit of using an enum rather than a #define constant?
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
What is structure packing in c?
What is a structural principle?
What is the value of a[3] if integer a[] = {5,4,3,2,1}?
Write a program to generate the Fibinocci Series
how to execute a program using if else condition and the output should enter number and the number is odd only...
What is an auto keyword in c?
How many keywords are there in c?