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
What is fflush() function?
What is the difference between array and structure in c?
which is an algorithm for sorting in a growing Lexicographic order
What is typedef?
Differentiate between ordinary variable and pointer in c.
FILE PROGRAMMING
Differentiate between declaring a variable and defining a variable?
write a C program: To search a file any word which starts with ?a?. If the word following this ?a? starts with a vowel.Then replace this ?a? with ?a? with ?an?. redirect with the output onto an output file.The source file and destination file are specified by the user int the command line.
Explain which function in c can be used to append a string to another string?
What are categories used for in c?
What are multidimensional arrays?
Can you tell me how to check whether a linked list is circular?
a program that can input number of records and can view it again the record
What is 02d in c?
What is an lvalue in c?