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.

Answer Posted / 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       View All Answers


Please Help Members By Posting Answers For Below Questions

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?

788


What is pointer to pointer in c language?

604


How can I write functions that take a variable number of arguments?

635


Devise a program that inputs a 3 digit number n and finds out whether the number is prime or not. Find out its factors.

676


Can you tell me how to check whether a linked list is circular?

787






What is zero based addressing?

724


How to throw some light on the b tree?

609


What does the c in ctime mean?

581


all c language question

1885


Can 'this' pointer by used in the constructor?

619


What does calloc stand for?

658


how to execute a program using if else condition and the output should enter number and the number is odd only...

1668


What are the two types of functions in c?

579


List the different types of c tokens?

631


Explain what is the benefit of using #define to declare a constant?

616