Write a program to find the smallest and largest element in
a given array in c language
Answer Posted / rajesh kumar s
int main()
{
int a[20],min,max;
int n;
printf("enter the num of elements\t:");
scanf("%d",&n);
printf("enter the elements\n");
for(int 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 ? | 234 Yes | 67 No |
Post New Answer View All Answers
Explain how do you search data in a data file using random access method?
What are the two types of functions in c?
What is a double c?
How is a structure member accessed?
What is a 'null pointer assignment' error?
how to write a c program to print list of fruits in alpabetical order?
Write a program to print "hello world" without using a semicolon?
Why & is used in c?
write a C program:There is a mobile keypad with numbers 0-9 and alphabets on it. Take input 0f 7 keys and then form a word from the alphabets present on the keys.
How to compare array with pointer in c?
Read the following data in two different files File A: aaaaaaaadddddddd bbbbbbbbeeeeeeee ccccccccffffffff File B: 11111111 22222222 33333333 By using the above files print the following output or write it in the Other file as follows aaaaaaaa11111111dddddddd bbbbbbbb22222222eeeeeeee cccccccc33333333ffffffffffff
What do you mean by a local block?
C language questions for civil engineering
Give differences between - new and malloc() , delete and free() ?
C program execution always begins with a) #include b) comment (/*-------*/) c) main() d) declaration instructions