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>
#include <conio.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);
getch();
}

Is This Answer Correct ?    3 Yes 2 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

Why doesnt that code work?

1097


a character or group of characters that defines a register,or a part of storage a) memory b) byte c) address d) linear list

975


Do string constants represent numerical values?

1344


Is register a keyword in c?

1003


How to explain the final year project as a fresher please answer with sample project

922


How to implement a packet in C

2853


Explain the array representation of a binary tree in C.

1181


What are the different types of control structures in programming?

1097


write a program in c language to print your bio-data on the screen by using functions.

6750


What is break statement?

1072


How can I rethow can I return a sequence of random numbers which dont repeat at all?

1163


Explain how are portions of a program disabled in demo versions?

1092


Is a pointer a kind of array?

1139


What is || operator and how does it function in a program?

1059


What is a pointer variable in c language?

1049