WRITE A C PROGRAM TO FIND SECOND BIGGEST VALUE FROM THE
GIVEN VALUES

Answer Posted / naveen

#include<stdio.h>
#include<math.h>
void main()
{
int a[],n,b;
printf("Enter the number of digits you want to enter:");
scanf(%d",&n);
printf("Enter the different values you want:")
for(i=0;i<=n;i++)
{
scanf(%d",a[i]);
}
/* This will make the values to be arranged in descending
order*/
for(i=0;i<=n;i++)
{
if(a[i] >> a[i+1])
{

}
else
{
b = a[i];
a[i] = a[i+1];
a[i+1] = b;
}
}
/* As a[0] will be the max value the next to it a[1] will be
second highest*/
printf("The second largest value will be: %d",&a[1]);
}

Is This Answer Correct ?    36 Yes 42 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

What is cohesion in c?

775


When we use void main and int main?

846


Read the following data in two different files File A: aaaaaaaadddddddd bbbbbbbbeeeeeeee ccccccccffffffff File B: 11111111 22222222 33333333 By using the above files print the following output or write it in the Other file as follows aaaaaaaa11111111dddddddd bbbbbbbb22222222eeeeeeee cccccccc33333333ffffffffffff

2936


What is the most efficient way to count the number of bits which are set in an integer?

854


How do you generate random numbers in C?

955


Why is a semicolon (;) put at the end of every program statement?

876


Why is structure padding done in c?

929


Difference between malloc() and calloc() function?

929


Explain the difference between #include "..." And #include <...> In c?

828


Why calloc is better than malloc?

823


How many identifiers are there in c?

809


Explain what is the difference between the expression '++a' and 'a++'?

915


Is Exception handling possible in c language?

1826


Is it better to use a macro or a function?

941


What are the 5 elements of structure?

860