Write a program to find the smallest and largest element in
a given array in c language
Answer Posted / alive
#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 ? | 15 Yes | 13 No |
Post New Answer View All Answers
Write a program to find factorial of a number using recursive function.
What is difference between scanf and gets?
p*=(++q)++*--p when p=q=1 while(q<=6)
What is this pointer in c plus plus?
Do array subscripts always start with zero?
What is New modifiers?
What is the value of uninitialized variable in c?
What is the scope of local variable in c?
What is the use of getchar() function?
Differentiate between a structure and a union.
Do pointers store the address of value or the actual value of a variable?
any function have arguments one or more OR not . it is compulsary a) any function compulsary have one or more arguments b) any function did not have arguments. It is not compulsary c) it is optional it is not compulsary d) none of the above
In the DOS enveronment, normal RAM that resides beyond the 1mb mark. a) expanded memory b) swapped memory c) Extended memory d) none
please give me some tips for the placement in the TCS.
What is the value of a[3] if integer a[] = {5,4,3,2,1}?