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 are c identifiers?
Why doesnt the call scanf work?
Explain can you assign a different address to an array tag?
illustrate the use of address operator and dereferencing operator with the help of a program guys plzzz help for this question
What are runtime error?
how do you programme Carrier Sense Multiple Access
Is there a way to jump out of a function or functions?
Do character constants represent numerical values?
What are c header files?
Can we change the value of constant variable in c?
What is the c value paradox and how is it explained?
Should I learn data structures in c or python?
Write a program that accept anumber in words
What is %s and %d in c?
What does printf does?