Write a program to find the smallest and largest element in
a given array in c language
Answer Posted / anudeep
#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 ? | 3 Yes | 2 No |
Post New Answer View All Answers
What is the significance of an algorithm to C programming?
What are pointers in C? Give an example where to illustrate their significance.
This is a variation of the call_me function in the previous question:call_me (myvar)int *myvar;{ *myvar += 5; }The correct way to call this function from main() will be a) call_me(myvar) b) call_me(*myvar) c) call_me(&myvar) d) expanded memory
List the difference between a "copy constructor" and a "assignment operator"?
What are the advantages and disadvantages of pointers?
How can I automatically locate a programs configuration files in the same directory as the executable?
Why pointers are used?
Which header file should you include if you are to develop a function which can accept variable number of arguments?
What are global variables?
What is null in c?
Explain what is the stack?
How would you rename a function in C?
Write a Program to find whether the given number or string is palindrome.
What does the function toupper() do?
What is the difference between far and near ?