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 header files are used?

633


Is Exception handling possible in c language?

1570


What is #include in c?

587


Tell me the use of bit field in c language?

616


What's the difference between constant char *p and char * constant p?

649






What is "Duff's Device"?

693


Why array is used in c?

547


Describe the steps to insert data into a singly linked list.

612


How many types of arrays are there in c?

585


Explain the use of function toupper() with and example code?

645


Explain with the aid of an example why arrays of structures don’t provide an efficient representation when it comes to adding and deleting records internal to the array.

2645


What is the use of getchar() function?

622


When should the const modifier be used?

648


What are the string functions? List some string functions available in c.

594


What are the 4 types of organizational structures?

613