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 / raj

#include <stdio.h>


void main()
{
int i, ar[] ={15,22,122,15,6,12};
int a,b= 0,c,ta ,tb, tc;
a =ar[0];
b = ar[1];

for (i = 0; i < 6 ;i++)
{
if(a > ar[i])
{
b = a;
a = ar[i];
}
else if(b > ar[i])
{
b = ar[i];
}
}

printf("\n %d ",b);
}

Is This Answer Correct ?    3 Yes 3 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

What are the types of pointers?

1032


What is optimization in c?

946


Can you subtract pointers from each other? Why would you?

915


How will you declare an array of three function pointers where each function receives two ints and returns a float?

1290


how to write optimum code to divide a 50 digit number with a 25 digit number??

3203


Are local variables initialized to zero by default in c?

982


How can I read data from data files with particular formats?

1002


What are the advantages of using macro in c language?

1066


Why is it important to memset a variable, immediately after allocating memory to it ?

1997


How many types of functions are there in c?

1060


What are the advantages and disadvantages of pointers?

1011


How to declare pointer variables?

1161


Why c language?

1005


What is the difference between struct and union in C?

1240


Can we declare variables anywhere in c?

947