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
hi... can anyone help me to make a two-dimensinal arrays in finding the sum of two elements plzzz. thnx a lot...
What are the basic data types associated with c?
Write program to remove duplicate in an array?
What are directives in c?
When should the register modifier be used? Does it really help?
Can you write a programmer for FACTORIAL using recursion?
I need testPalindrome and removeSpace
#include
What is the explanation for prototype function in c?
Is there any possibility to create customized header file with c programming language?
write a program fibonacci series and palindrome program in c
Which is better between malloc and calloc?
How to get string length of given string in c?
What is the difference between functions abs() and fabs()?
When would you use a pointer to a function?
"C" language developed by "Dennis Ritchie" at AT & T. his remarks are a) too general, too abstract b) could deal with only specific problems c) lost generality of BCPL and B restored d) no remarks