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
Is main is a keyword in c?
Tell me what is null pointer in c?
What are the ways to a null pointer can use in c programming language?
Explain how do you determine a file’s attributes?
formula to convert 2500mmh2o into m3/hr
What is the process to create increment and decrement stamen in c?
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.
What is the use of gets and puts?
Explain the array representation of a binary tree in C.
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)
I need previous papers of CSC.......plz help out by posting them.......
What is wrong with this declaration?
Is python a c language?
When would you use a pointer to a function?
What is difference between structure and union in c?