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
Using which language Test cases are added in .ptu file of RTRT unit testing???
Explain how do you convert strings to numbers in c?
which of the following is allowed in a "C" arithematic instruction a) [] b) {} c) () d) none of the above
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.
What are directives in c?
Can you pass an entire structure to functions?
What is difference between && and & in c?
write a c program in such a way that if we enter the today date the output should be next day's date.
I need a help with a program: Write a C program that uses data input in determining the whole of points A and a whole of circles B. Find two points in A so that the line which passes through them, cut through the maximum number of circles.
What is 2 d array in c?
Write a program to input the price of 1 burger and the number of burgers eaten by a group of friends .print the total amount to be paid by the group?
Explain what are preprocessor directives?
What are called c variables?
What is the purpose of void in c?
What is line in c preprocessor?