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

with respect to solution posted by "Hari Prasad Perabattula"

if(n%2) {
if(arr[2] < min)
min = arr[2];
if(arr[2] > max)
max = arr[2];
start = 3;
}

must be changed as

if(n%2) {
if(arr[2] < tmin)
tmin = arr[2];
if(arr[2] > tmax)
tmax = arr[2];
start = 3;
}

bcos if the 3 element in the array is the smallest then we
ignore that once we enter the for loop if min and max are
updated.

Is This Answer Correct ?    15 Yes 26 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

Compare array data type to pointer data type

1018


Is c language still used?

977


What is the difference between fread and fwrite function?

1077


What is union and structure in c?

1215


How do I use void main?

1089


What is the incorrect operator form following list(== , <> , >= , <=) and what is the reason for the answer?

1458


write a c program to print the next of a particular no without using the arithmetic operator or looping statements?

3945


Can you explain what keyboard debouncing is, and where and why we us it? please give some examples

2188


Explain Function Pointer?

1160


Explain the binary height balanced tree?

1181


Explain what is the difference between functions getch() and getche()?

1049


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

1051


how to solve "unable to open stdio.h and conio.h header files in windows 7 by using Dos-box software

3311


What are the types of operators in c?

1055


What is the use of in c?

1025