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 / rajesh kumar s

int main()
{
int a[20],min,max;
int n;
printf("enter the num of elements\t:");
scanf("%d",&n);

printf("enter the elements\n");
for(int 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 ?    234 Yes 67 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

What is difference between && and & in c?

1045


Define the scope of static variables.

1063


Hello. How to write a C program to check and display president party like if i type in the console "biden" and hit enter the output shoud be : "biden is democrat" and if i type "trump" and hit enter the output shoud be: "trump is republican"

2033


write a programe to accept any two number and check the following condition using goto state ment.if a>b,print a & find whether it is even or odd and then print.and a

1884


What does it mean when the linker says that _end is undefined?

1039


What are the parts of c program?

1040


why do some people write if(0 == x) instead of if(x == 0)?

1011


What is define directive?

1073


What is a null string in c?

988


How can you invoke another program from within a C program?

1023


How arrays can be passed to a user defined function

966


Is a pointer a kind of array?

1115


the maximum length of a character constant can be a) 1 character b) 8 characters c) 256 chaacters d) 125 characters

2234


Can include files be nested? How many levels deep can include files be nested?

1087


What is meant by operator precedence?

1095