Write a program that read 2o numbers in and array and
output the second largest number. Can anybody help??
Answer Posted / ajit
#include<stdio.h>
void main()
{
int a[20],i,j,temp;
printf("enter the 20 values\n");
for(i=0;i<20;i++)
scanf("%d",&a[i]);
for(i=0;i<20;i++)
{
for(j=i+1;j<20;j++)
{
if(a[i]>a[j])
{
temp=a[i];
a[i]=a[j];
a[j]=temp;
}
}
}
printf("the second largest number is %d\n",a[18]);
}
| Is This Answer Correct ? | 0 Yes | 1 No |
Post New Answer View All Answers
Will a recursive function without an end condition every quit, in practice a) Compiler-Specific (Some can convert to an infinite loop) b) No c) Yes
What are guid?
why is c++ called oops? Explain
How can you prevent accessing of the private parts of my class by other programmers (violating encapsulation)?
What are register variables?
What size is allocated to the union variable?
Define a nested class. Explain how it can be useful.
What is the difference between the indirection operator and the address of oper-ator?
What is binary search in c++?
How much is c++ certification?
What are the manipulators in c++?
What is the difference between a reference and a pointer?
Assume an array of structure is in order by studentID field of the record, where student IDs go from 101 to 500. Write the most efficient pseudocode algorithm you can to find the record with a specific studentID if every single student ID from 101 to 500 is used and the array has 400 elements. Write the most efficient pseudocode algorithm you can to find a record with a studentID near the end of the IDs, say in the range from 450 to 500, if not every single student ID in the range of 101 to 500 is used and the array size is only 300
What is the use of register keyword with the variables?
What is #include ctype h in c++?