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

#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 ?    15 Yes 13 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

Explain about the functions strcat() and strcmp()?

1053


What is LINKED LIST? How can you access the last element in a linked list?

1075


The difference between printf and fprintf is ?

1290


What is main () in c language?

1134


disply the following menu 1.Disply 2.Copy 3.Append; as per the menu do the file operations 4.Exit

2076


Why dont c comments nest?

1050


What is the size of enum in bytes?

1090


What is conio h in c?

1049


Difference between goto, long jmp() and setjmp()?

1182


In a switch statement, what will happen if a break statement is omitted?

1066


Why & is used in c?

1192


What is modeling?

1055


Is using exit() the same as using return?

1361


Can a pointer point to null?

1069


How many parameters should a function have?

1195