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
Explain the difference between null pointer and void pointer.
What is a union?
what is the structure pointer?
Is using exit() the same as using return?
What is the difference between scanf and fscanf?
Explain what is #line used for?
Ow can I insert or delete a line (or record) in the middle of a file?
Explain what is the difference between the expression '++a' and 'a++'?
What is the general form of #line preprocessor?
Some coders debug their programs by placing comment symbols on some codes instead of deleting it. How does this aid in debugging?
What language is lisp written in?
If a variable is a pointer to a structure, then which operator is used to access data members of the structure through the pointer variable?
Can the curly brackets { } be used to enclose a single line of code?
What kind of structure is a house?
What extern c means?