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

how to swap 2 numbers within a single statement?

4 Answers  


When should structures be passed by values or by references?

0 Answers   Adobe,


Write a function that accepts a sentence as a parameter, and returns the same with each of its words reversed. The returned sentence should have 1 blank space between each pair of words. Demonstrate the usage of this function from a main program. Example: Parameter: “jack and jill went up a hill” Return Value: “kcaj dna llij tnew pu a llih”

5 Answers   Mind Tree,


Can we assign integer value to char in c?

0 Answers  


How the c program is executed?

0 Answers  


How can I make it pause before closing the program output window?

0 Answers  


What is break statement?

0 Answers  


How to implement call back functions ?

3 Answers   HP,


In c programming, explain how do you insert quote characters (? And ?) Into the output screen?

0 Answers  


hi send me sample aptitude papers of cts?

0 Answers  


every function has return the value?

1 Answers  


Tell us something about keyword 'auto'.

0 Answers  


Categories