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 to fined second smallest and largest element
in a given series of elements (without sorting)

Answer Posted / vadivel t

#include<stdio.h>

void main()
{
int a[10] = {5,4,1,7,3,0,8,23,12,24};
int Lcount = 0, Gcount = 0, i, j;

for(i = 0; i<10; i++)
{
Gcount = 0;
Lcount = 0;
for(j = 0; j<10; j++)
{
if(a[i] > a[j])
{
Gcount++;
Lcount++;
}
}
if(Gcount == 8)
{
printf("The second largest no is: %
d \n", a[i]);
}
if(Lcount == 1)
{
printf("The second smallest no is: %
d \n", a[i]);
}
}
_getch();
}

Is This Answer Correct ?    2 Yes 4 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

Are there namespaces in c?

1120


Are local variables initialized to zero by default in c?

1046


What is the best way to store flag values in a program?

1070


number of times a digit is present in a number

2038


c program to compute AREA under integral

2394


How do I send escape sequences to control a terminal or other device?

1070


printf(), scanf() these are a) library functions b) userdefined functions c) system functions d) they are not functions

1154


How to throw some light on the b tree?

1081


Explain what are multidimensional arrays?

1063


What is use of integral promotions in c?

1146


What is oops c?

1236


How do you use a 'Local Block'?

1166


How is a structure member accessed?

1127


What is adt in c programming?

1158


What are c preprocessors?

1185