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
What is difference between && and & in c?
Define the scope of static variables.
Hello. How to write a C program to check and display president party like if i type in the console "biden" and hit enter the output shoud be : "biden is democrat" and if i type "trump" and hit enter the output shoud be: "trump is republican"
write a programe to accept any two number and check the following condition using goto state ment.if a>b,print a & find whether it is even or odd and then print.and a
What does it mean when the linker says that _end is undefined?
What are the parts of c program?
why do some people write if(0 == x) instead of if(x == 0)?
What is define directive?
What is a null string in c?
How can you invoke another program from within a C program?
How arrays can be passed to a user defined function
Is a pointer a kind of array?
the maximum length of a character constant can be a) 1 character b) 8 characters c) 256 chaacters d) 125 characters
Can include files be nested? How many levels deep can include files be nested?
What is meant by operator precedence?