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 |
How do i store a paragraph into a string? for example, if i input a long paragraph, the program will read the words one by one and concatenate them until no word is left.
What are the data types present in c?
how do you programme Carrier Sense Multiple Access
who is the father of c
how c source file in converted to exe file
Switch (i) i=1; case 1 i++; case 2 ++i; break; case 3 --i; Output of i after executing the program
What is the difference between exit() and _exit()?
Why main function is special give two reasons?
with out using main how to execute the program?
Explain high-order and low-order bytes.
Write a factorial program using C.
What is the use of in c?