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

Why c is called free form language?

575


What is the advantage of an array over individual variables?

746


What does a pointer variable always consist of?

667


Explain what will be the outcome of the following conditional statement if the value of variable s is 10?

752


What is the value of h?

597






What is a #include preprocessor?

623


Explain what is the difference between a string copy (strcpy) and a memory copy (memcpy)? When should each be used?

607


What is a stream water?

663


Explain what is a 'locale'?

587


Is c a great language, or what?

608


What are the types of macro formats?

613


When should a type cast be used?

577


Is there any data type in c with variable size?

636


Are pointers integer?

554


write a program fibonacci series and palindrome program in c

633