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
What does. int *x[](); means ?
Hai what is the different types of versions and their differences
Explain union.
a formula,a series of steps,or well defined set of rules for solving a problem a) algorithem b) program c) erdiagram d) compiler
Can two or more operators such as and be combined in a single line of program code?
What are the header files used in c language?
What is "Duff's Device"?
7-Given an index k, return the kth row of the Pascal's triangle. For example, when k = 3, the row is [1,3,3,1]. For reference look at the following standard pascal’s triangle.
I came across some code that puts a (void) cast before each call to printf. Why?
Hi how many types of software editions are there and their difference (like home editions, enterprise, standard etc) can u please help me
which is an algorithm for sorting in a growing Lexicographic order
What is a structural principle?
explain what is an endless loop?
What is the use of void pointer and null pointer in c language?
What are the standard predefined macros?