Write a program to find the smallest and largest element in
a given array in c language
Answer Posted / anudeep
#include <stdio.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);
| Is This Answer Correct ? | 3 Yes | 6 No |
Post New Answer View All Answers
Here is a neat trick for checking whether two strings are equal
What is the difference between void main and main in c?
What is an operator?
Explain what are header files and explain what are its uses in c programming?
Is c easy to learn?
What is the difference between typedef and #define?
What is a scope resolution operator in c?
please give me a VIRTUSA sample palcement papers.... you will only send TECHNICAL SECTION..... that is help for me Advance Thanks........................
Subtract Two Number Without Using Subtraction Operator
Create a structure to specify data on students as given below: Roll number, Name, Department, Course, and Year of joining. Assume that there are not more than 450 students in the collage. (a) Write a function to print the names of all students who joined in the last 3 years. (b) Write a function to print the data of a student whose roll numbers are divisible by 4.
write a program fibonacci series and palindrome program in c
What is a volatile keyword in c?
What are the header files used in c language?
What is the correct declaration of main?
where are auto variables stored? What are the characteristics of an auto variable?