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 hash table in c?

989


What is operator promotion?

1024


Why void is used in c?

972


how to execute a program using if else condition and the output should enter number and the number is odd only...

2229


Are there any problems with performing mathematical operations on different variable types?

1011


What is return in c programming?

936


Is null always defined as 0(zero)?

1064


When a c file is executed there are many files that are automatically opened what are they files?

1073


Do array subscripts always start with zero?

1253


What is null in c?

1026


what is event driven software and what is procedural driven software?

2518


How old is c programming language?

975


What does volatile do?

948


How main function is called in c?

1087


What is meant by 'bit masking'?

1348