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
Why c is called free form language?
What is the advantage of an array over individual variables?
What does a pointer variable always consist of?
Explain what will be the outcome of the following conditional statement if the value of variable s is 10?
What is the value of h?
What is a #include preprocessor?
Explain what is the difference between a string copy (strcpy) and a memory copy (memcpy)? When should each be used?
What is a stream water?
Explain what is a 'locale'?
Is c a great language, or what?
What are the types of macro formats?
When should a type cast be used?
Is there any data type in c with variable size?
Are pointers integer?
write a program fibonacci series and palindrome program in c