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 find the largest and second largest
integer from an array

Answer Posted / manish gupta

#include<stdio.h>
#include<conio.h>
void main()
{
int a[5],x,y,c;
for (x=0;x<5;x++)
{
printf("enter any number");
scanf("%d",&a[x]);
}
for (x=0;x<5;x++)
{
for (y=0;y<4;y++)
{
if (a[y]>a[y+1])
{
c=a[y];
a[y]=a[y+1];
a[y+1]=c;
}
}
}
printf("\nlargest no:-%d",a[y]);
printf("\nsecond largest no:-%d",a[y-1]);
getch();
}

Is This Answer Correct ?    17 Yes 8 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

Why does not c have an exponentiation operator?

1115


Implement bit Array in C.

1199


Why should I use standard library functions instead of writing my own?

1313


what are the program that using a two dimensional array that list the odd numbers and even numbers separately in a given 10 inputs values

1755


Write a C program in Fibonacci series.

1135


How can you access memory located at a certain address?

1162


What are the back slash character constants or escape sequence charactersavailable in c?

1230


Why does everyone say not to use gets?

1199


In C programming, what command or code can be used to determine if a number of odd or even?

1093


Is that possible to store 32768 in an int data type variable?

1136


What does the function toupper() do?

1192


How do you convert strings to numbers in C?

1296


What is the difference between c and python?

1233


How can I ensure that integer arithmetic doesnt overflow?

1254


To print the pattern 1 2 3 4 5 10 17 18 19 6 15 24 25 20 7 14 23 22 21 8 13 12 11 10 9

2689