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 are the advantages of using macro in c language?
What does s c mean on snapchat?
Why do we use null pointer?
What is the value of a[3] if integer a[] = {5,4,3,2,1}?
What are the types of unary operators?
What is the size of a union variable?
If a variable is a pointer to a structure, then which operator is used to access data members of the structure through the pointer variable?
What is typedf?
What do you understand by friend-functions? How are they used?
Why pointers are used?
Do pointers take up memory?
Can we declare variables anywhere in c?
writ a program to compare using strcmp VIVA and viva with its output.
Explain how can I pad a string to a known length?
What is the acronym for ansi?