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
Compare array data type to pointer data type
Is c language still used?
What is the difference between fread and fwrite function?
What is union and structure in c?
How do I use void main?
What is the incorrect operator form following list(== , <> , >= , <=) and what is the reason for the answer?
write a c program to print the next of a particular no without using the arithmetic operator or looping statements?
Can you explain what keyboard debouncing is, and where and why we us it? please give some examples
Explain Function Pointer?
Explain the binary height balanced tree?
Explain what is the difference between functions getch() and getche()?
How can I prevent another program from modifying part of a file that I am modifying?
how to solve "unable to open stdio.h and conio.h header files in windows 7 by using Dos-box software
What are the types of operators in c?
What is the use of in c?