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
What is the purpose of macro in C language?
What will be the outcome of the following conditional statement if the value of variable s is 10?
Write a program to implement a round robin scheduler and calculate the average waiting time.Arrival time, burst time, time quantum, and no. of processes should be the inputs.
Explain how do you declare an array that will hold more than 64kb of data?
Describe static function with its usage?
Combinations of fibanocci prime series
Is c still used?
Write a program to reverse a string.
Why header file is used in c?
An organised method of depicting the use of an area of computer memory used to signify the uses for different parts of the memory a) swap b) extended memory c) memory map d) all of the above
how can f be used for both float and double arguments in printf? Are not they different types?
List some basic data types in c?
Here is a neat trick for checking whether two strings are equal
What does *p++ do?
Can variables be declared anywhere in c?