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


Please Help Members By Posting Answers For Below Questions

write a program to create a sparse matrix using dynamic memory allocation.

4374


What are conditional operators in C?

628


What's the total generic pointer type?

616


Differentiate between static and dynamic modeling.

621


hi... can anyone help me to make a two-dimensinal arrays in finding the sum of two elements plzzz. thnx a lot...

1447






i have to apply for rbi before that i need to know the the syllabus for the entrance questions. whethet it may be aps or techinical

1845


What is the difference between union and anonymous union?

837


Write a program to print factorial of given number without using recursion?

570


How can I discover how many arguments a function was actually called with?

636


How can I direct output to the printer?

814


When I tried to go into a security sites I am denied access and a message appeared saying 'applet not initialize'. How can I rectify this problem.

1532


hai iam working in sap sd module for one year and working in lumax ind ltd in desp department but my problem is i have done m.b.a in hr/marketing and working sap sd there is any combination it. can you give right solution of my problem. and what can i do?

1666


What are pointers in C? Give an example where to illustrate their significance.

752


What is structure data type in c?

574


What is the hardest programming language?

672