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

Why do some versions of toupper act strangely if given an upper-case letter?

1050


How do you initialize pointer variables?

1043


How the c program is executed?

1093


What does *p++ do? What does it point to?

1012


What is a const pointer?

1051


Write a program to print "hello world" without using a semicolon?

1022


Why isnt any of this standardized in c?

1029


Can we change the value of #define in c?

970


What is masking?

1110


Explain how can you check to see whether a symbol is defined?

1110


How can you access memory located at a certain address?

1071


What is the value of a[3] if integer a[] = {5,4,3,2,1}?

1049


Can math operations be performed on a void pointer?

1004


 write a program that will open the file, count the number of occurences of each word in the the complete works of shakespeare.  You will then tabulate this information in another file.

2170


What is a pointer on a pointer in c programming language?

1101