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
difference between object file and executable file
What is context in c?
What is the difference between null pointer and wild pointer?
Distinguish between actual and formal arguments.
Explain a pre-processor and its advantages.
What will the preprocessor do for a program?
pgm to find number of words starting with capital letters in a file(additional memory usage not allowed)(if a word starting with capital also next letter in word is capital cann't be counted twice)
write a c program for swapping two strings using pointer
Why cant I open a file by its explicit path?
Why should I use standard library functions instead of writing my own?
what is the difference between class and unio?
Why do we use header files in c?
What are the ways to a null pointer can use in c programming language?
Where are some collections of useful code fragments and examples?
why wipro wase