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
How does normalization of huge pointer works?
What does stand for?
Why c language is called c?
What is the difference between text files and binary files?
Why is this loop always executing once?
Hai sir, I had planned to write the NIC scientific engineer exam , plz post the sample question......
What is the difference between int main and void main in c?
Why main function is special give two reasons?
What is bin sh c?
What is %d called in c?
Are there any problems with performing mathematical operations on different variable types?
What are bitwise shift operators in c programming?
What are the various types of control structures in programming?
Are comments included during the compilation stage and placed in the EXE file as well?
What is the heap in c?