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

Describe wild pointers in c?

1108


Explain pointers in c programming?

1106


Are global variables static in c?

1159


What is the significance of c program algorithms?

1141


How do I determine whether a character is numeric, alphabetic, and so on?

1127


Explain what is the difference between a free-standing and a hosted environment?

1182


What does *p++ do? What does it point to?

1058


What is the right type to use for boolean values in c?

1028


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?

2123


Explain the use of bit fieild.

1137


When can a far pointer be used?

1021


Explain heap and queue.

1074


what is the height of tree if leaf node is at level 3. please explain

2147


Explain what could possibly be the problem if a valid function name such as tolower() is being reported by the c compiler as undefined?

1005


Does sprintf put null character?

1035