write a program in c language that uses function to locate
and return the smallest and largest integers in an
array,number and their position in the array. it should
also find and return the range of the numbers , that is ,
the difference between the largest number and the smallest.



write a program in c language that uses function to locate and return the smallest and largest int..

Answer / vadivelt

Hi Guys,
Pls Post some unusual and difficult questions. These qns
are very common. Anyway am posting the answer.

Code is here.,

#include<stdio.h>
#include<conio.h>
void main()
{
int a[100];
int count, i, j, temp;
printf("ENTER THE NO OF ELEMENTS IN THE ARRAY\n");
scanf("%d", &count);
printf("ENTER THE ARRAY ELEMENTS\n");
for(i = 0; i<count;i++)
{
scanf("%d", &a[i]);
}
for(i = 0; i<count; i++)
{
for(j = i+1; j<count; j++)
{
if(a[i] > a[j])
{
temp = a[i];
a[i] = a[j];
a[j] = temp;
}
}
}
printf("\nLargest no is: %d \n", a[count-1]);

printf("Smallest no is: %d \n", a[0]);
printf("Differance is: %d \n", a[count-1] - a[0]);
getch();
}

Is This Answer Correct ?    10 Yes 1 No

Post New Answer

More C Interview Questions

What is a C array and illustrate the how is it different from a list.

1 Answers   Amazon,


Explain what is the use of a semicolon (;) at the end of every program statement?

0 Answers  


what is the format specifier for printing a pointer value?

0 Answers  


What are the types of pointers in c?

0 Answers  


How can I find leaf node with smallest level in a binary tree?

1 Answers  






How the processor registers can be used in C ?

7 Answers   HP,


main use of recursive function a) processing speed high b) reduce program length/reduce repeated statements c) if you do not, use iterative methods like, for, while or do-while d) all the above

0 Answers  


What is 'bus error'?

0 Answers  


What does the message "warning: macro replacement within a string literal" mean?

1 Answers  


What are the 4 types of functions?

0 Answers  


what will be maximum number of comparisons when number of elements are given?

0 Answers  


What does calloc stand for?

0 Answers  


Categories