Golgappa.net | Golgappa.org | BagIndia.net | BodyIndia.Com | CabIndia.net | CarsBikes.net | CarsBikes.org | CashIndia.net | ConsumerIndia.net | CookingIndia.net | DataIndia.net | DealIndia.net | EmailIndia.net | FirstTablet.com | FirstTourist.com | ForsaleIndia.net | IndiaBody.Com | IndiaCab.net | IndiaCash.net | IndiaModel.net | KidForum.net | OfficeIndia.net | PaysIndia.com | RestaurantIndia.net | RestaurantsIndia.net | SaleForum.net | SellForum.net | SoldIndia.com | StarIndia.net | TomatoCab.com | TomatoCabs.com | TownIndia.com
Interested to Buy Any Domain ? << Click Here >> for more details...

Write a program to find the smallest and largest element in
a given array in c language

Answer Posted / dinesh

#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 ?    11 Yes 9 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

What is difference between main and void main?

1224


What is pointer in c?

1206


What does sizeof return c?

1073


What oops means?

1008


Can you apply link and association interchangeably?

1127


What does malloc () calloc () realloc () free () do?

1071


What is the equivalent code of the following statement in WHILE LOOP format?

1307


Explain how can you restore a redirected standard stream?

1102


Where are c variables stored in memory?

1079


When should you not use a type cast?

1128


What is identifiers in c with examples?

1185


What is the difference between char array and char pointer?

1065


How can I find out the size of a file, prior to reading it in?

1182


what is the difference between north western polytechnique university and your applied colleges?? please give ur answers for this. :)

2416


How can I write a function analogous to scanf?

1192