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

Is main is a keyword in c?

602


Tell me what is null pointer in c?

611


What are the ways to a null pointer can use in c programming language?

588


Explain how do you determine a file’s attributes?

588


formula to convert 2500mmh2o into m3/hr

493






What is the process to create increment and decrement stamen in c?

583


Write a programme using structure that create a record of students. The user allow to add a record and delete a record and also show the records in ascending order.

1617


What is the use of gets and puts?

599


Explain the array representation of a binary tree in C.

724


write a program to input 10 strings and compare without using strcmp() function. If the character of one string matches with the characters of another string , sort them and make it a single string ??? example:- str1="Aakash" st2="Himanshu" str="Uday" output:- Aakashimanshuday (please post the answer as quickly as possible)

1623


I need previous papers of CSC.......plz help out by posting them.......

1814


What is wrong with this declaration?

608


Is python a c language?

550


When would you use a pointer to a function?

584


What is difference between structure and union in c?

542