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 / 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


Please Help Members By Posting Answers For Below Questions

What are c identifiers?

1054


Why doesnt the call scanf work?

1151


Explain can you assign a different address to an array tag?

1020


illustrate the use of address operator and dereferencing operator with the help of a program guys plzzz help for this question

2037


What are runtime error?

1094


how do you programme Carrier Sense Multiple Access

1939


Is there a way to jump out of a function or functions?

1053


Do character constants represent numerical values?

1301


What are c header files?

962


Can we change the value of constant variable in c?

1020


What is the c value paradox and how is it explained?

1008


Should I learn data structures in c or python?

994


Write a program that accept anumber in words

1722


What is %s and %d in c?

987


What does printf does?

1204