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 the main difference between calloc () and malloc ()?

853


Is flag a keyword in c?

919


Why is struct padding needed?

828


Explain how can I prevent another program from modifying part of a file that I am modifying?

872


Write a c program to demonstrate character and string constants?

1924


Difference between constant pointer and pointer to a constant.

835


How do you determine a file’s attributes?

822


Write a code on reverse string and its complexity.

795


Write the program with at least two functions to solve the following problem. The members of the board of a small university are considering voting for a pay increase for their 10 faculty members. They are considering a pay increase of 8%. Write a program that will prompt for and accept the current salary for each of the faculty members, then calculate and display their individual pay increases. At the end of the program, print the total faculty payroll before and after the pay increase, and the total pay increase involved.

2889


What is void main ()?

812


Explain what is the purpose of "extern" keyword in a function declaration?

823


How do you do dynamic memory allocation in C applications?

845


Differentiate between declaring a variable and defining a variable?

833


which of the following is allowed in a "C" arithematic instruction a) [] b) {} c) () d) none of the above

1428


What is methods in c?

842