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
What is else syntax in c++?
What is an overflow error?
What are the benefits of c++?
What are the rules about using an underscore in a c++ identifier?
What is the full form of c++?
how can i access a direct (absolute, not the offset) memory
address?
here is what i tried:
wrote a program that ask's for an address from the user,
creates a FAR pointer to that adress and shows it. then the
user can increment/decrement the value in that address by
pressing p(inc+) and m(dec-).
NOW, i compiled that program and opened it twice (in 2
different windows) and gave twice the same address to it.
now look what happen - if i change the value in
one "window" of the program, it DOES NOT change in the
other! even if they point to the same address in the memory!
here is the code snippet:
//------------------------------------------------------
#include What are the advantages of c++? Explain How do I run c++? Draw a flow chart and write a program for the difference
between the sum of elements with odd and even numbers.
Two dimensional array. What kind of problems can be solved by a namespace? What is static class data? What is an html tag? How can you prevent accessing of the private parts of my class by other programmers (violating encapsulation)? declare an array of structure where the members of the
structure are integer variable float variable integer array
char variable access all elements of the structure using dot
operator and this pointer operator Define pre-condition and post-condition to a member function in c++?