Write a program to find the smallest and largest element in
a given array in c language
Answer Posted / puspendu adak
#include<stdio.h>
#include<conio.h>
void main()
{clrscr();
int i,arrb,arrl,arr[20],num;
printf("enter the number of elements");
scanf("%d",&num);
printf("enter the elements");
for(i=0;i<num;i++)
scanf("%d",&arr[i]);
arrl=arrb=arr[0];
for(i=0;i<num;i++)
{if(arr[i]>=arrb)
arrb=arr[i];
}
for(i=0;i<num;i++)
{if(arr[i]<arrl)
arrl=arr[i];
}
printf("the smallest number is %d.\nthe biggest number is
%d.",arrl,arrb);
getch();
}
Is This Answer Correct ? | 27 Yes | 22 No |
Post New Answer View All Answers
When should a type cast not be used?
Explain how can you check to see whether a symbol is defined?
Is fortran faster than c?
What is dangling pointer in c?
What is the difference between #include and #include 'file' ?
How can I recover the file name given an open stream or file descriptor?
What are the types of data structures in c?
Is a house a shell structure?
What are reserved words with a programming language?
Explain the red-black trees?
An expression to whose value an operater is applied a) operand b) variable c) constant d) all of the above
What is typedf?
What is output redirection?
What is mean by data types in c?
What is a memory leak? How to avoid it?