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

# include<stdio.h>

void main()
{
int a[10];
int max=0,min=0,n,i=0;

printf("enter array size");
scanf("%d",&n);

printf("enter elements");
for( i=0;i<n;i++)
{

scanf("%d",&a[i]);
}

//mini num
min=a[i];
for(int i=1;i<n;i++)
{

if(min>a[i])
{
min=a[i++];
}
}

//max num
max=a[i];
for(int i=1;i<n;i++)
{

if(max<a[i])
{
max=a[i++];
}
}

printf( "min=%d max=%d",min,max);
getch();
}

Is This Answer Correct ?    21 Yes 17 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

What are the rules for the identifier?

1169


How can a number be converted to a string?

1340


Why malloc is faster than calloc?

1067


Explain continue keyword in c

1021


If one class contains another class as a member, in what order are the two class constructors called a) Constructor for the member class is called first b) Constructor for the member class is called second c) Only one of the constructors is called d) all of the above

1066


how many key words availabel in c a) 28 b) 31 c) 32

1081


What is multidimensional arrays

1130


Write a program to implement queue.

1122


What are the ways to a null pointer can use in c programming language?

1137


Explain is it better to use a pointer to navigate an array of values, or is it better to use a subscripted array name?

1222


c program to compute AREA under integral

2407


What is function definition in c?

1077


Explain how can I prevent another program from modifying part of a file that I am modifying?

1094


What is a memory leak? How to avoid it?

1350


in iso what are the common technological language?

2117