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

Describe newline escape sequence with a sample program?

1072


When would you use a pointer to a function?

993


write a programe to accept any two number and check the following condition using goto state ment.if a>b,print a & find whether it is even or odd and then print.and a

1885


How can you allocate arrays or structures bigger than 64K?

1083


What does char * * argv mean in c?

999


What is scanf_s in c?

1067


write a program to concatenation the string using switch case?

2035


What are valid signatures for the Main function?

1170


Write an algorithm for implementing insertion and deletion operations in a singly linked list using arrays ?

3457


What is #include conio h?

945


Why do we write return 0 in c?

1006


Explain how to reverse singly link list.

1073


What are the basic data types associated with c?

1220


What is pointer to pointer in c with example?

982


Difference between exit() and _exit() function?

1077