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

What is a newline escape sequence?

1053


What is the difference between c and python?

1102


What is the best way of making my program efficient?

961


What is %lu in c?

1176


Write a function stroverlap that takes (at least) two strings, and concatenates them, but does not duplicate any overlap. You only need to worry about overlaps between the end of the first string and the beginning of the second string. Examples: batman, manonthemoon = batmanonthemoon batmmamaman, mamamanonthemoon = batmmamamanonthemoon bat, man = batman batman, batman = batman batman, menonthemoon = batmanmenonthemoon

2228


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

1018


Which control loop is recommended if you have to execute set of statements for fixed number of times?

1297


What is the difference between printf and scanf in c?

1284


What is the explanation for the dangling pointer in c?

1061


What is typeof in c?

952


What is main function in c?

1013


Can we assign integer value to char in c?

1155


Why c is called free form language?

968


program for reversing a selected line word by word when multiple lines are given without using strrev

2420


Write the program that calculates and prints the average of several integers. Assume that the last value read is sentinel 9999.

3635