Write a program to find the smallest and largest element in
a given array in c language
Answer Posted / anudeep
#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 ? | 3 Yes | 2 No |
Post New Answer View All Answers
Why doesnt that code work?
a character or group of characters that defines a register,or a part of storage a) memory b) byte c) address d) linear list
Do string constants represent numerical values?
Is register a keyword in c?
How to explain the final year project as a fresher please answer with sample project
How to implement a packet in C
Explain the array representation of a binary tree in C.
What are the different types of control structures in programming?
write a program in c language to print your bio-data on the screen by using functions.
What is break statement?
How can I rethow can I return a sequence of random numbers which dont repeat at all?
Explain how are portions of a program disabled in demo versions?
Is a pointer a kind of array?
What is || operator and how does it function in a program?
What is a pointer variable in c language?