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 / 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 |
what is the use of macro program
write a c program for swapping two strings using pointer
What's the difference between calloc() and malloc()?
Differentiate between new and malloc(), delete and free() ?
hi, which software companys will take,if d candidate's % is jst 55%?
fn f(x) { if(x<=0) return; else f(x-1)+x; }
how can be easily placed in TCS.
how does a general function , that accepts an array as a parameter, "knows" the size of the array ? How should it define it parameters list ?
Function calling procedures? and their differences? Why should one go for Call by Reference?
How do you write a program which produces its own source code as its output?
c pgm count no of lines , blanks, tabs in a para(File concept)
What is the most efficient way to count the number of bits which are set in a value?