Golgappa.net | Golgappa.org | BagIndia.net | BodyIndia.Com | CabIndia.net | CarsBikes.net | CarsBikes.org | CashIndia.net | ConsumerIndia.net | CookingIndia.net | DataIndia.net | DealIndia.net | EmailIndia.net | FirstTablet.com | FirstTourist.com | ForsaleIndia.net | IndiaBody.Com | IndiaCab.net | IndiaCash.net | IndiaModel.net | KidForum.net | OfficeIndia.net | PaysIndia.com | RestaurantIndia.net | RestaurantsIndia.net | SaleForum.net | SellForum.net | SoldIndia.com | StarIndia.net | TomatoCab.com | TomatoCabs.com | TownIndia.com
Interested to Buy Any Domain ? << Click Here >> for more details...


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.



write a program in c language that uses function to locate and return the smallest and largest int..

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

Post New Answer

More C Interview Questions

what is the use of macro program

1 Answers   TCS,


write a c program for swapping two strings using pointer

0 Answers  


What's the difference between calloc() and malloc()?

4 Answers  


Differentiate between new and malloc(), delete and free() ?

0 Answers   iNautix,


hi, which software companys will take,if d candidate's % is jst 55%?

0 Answers  


fn f(x) { if(x<=0) return; else f(x-1)+x; }

5 Answers   HCL,


how can be easily placed in TCS.

0 Answers   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 ?

0 Answers  


Function calling procedures? and their differences? Why should one go for Call by Reference?

0 Answers   ADP,


How do you write a program which produces its own source code as its output?

2 Answers  


c pgm count no of lines , blanks, tabs in a para(File concept)

2 Answers  


What is the most efficient way to count the number of bits which are set in a value?

4 Answers  


Categories