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
What is a newline escape sequence?
What is the difference between c and python?
What is the best way of making my program efficient?
What is %lu in c?
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
What is LINKED LIST? How can you access the last element in a linked list?
Which control loop is recommended if you have to execute set of statements for fixed number of times?
What is the difference between printf and scanf in c?
What is the explanation for the dangling pointer in c?
What is typeof in c?
What is main function in c?
Can we assign integer value to char in c?
Why c is called free form language?
program for reversing a selected line word by word when multiple lines are given without using strrev
Write the program that calculates and prints the average of several integers. Assume that the last value read is sentinel 9999.