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
What is the main difference between calloc () and malloc ()?
Is flag a keyword in c?
Why is struct padding needed?
Explain how can I prevent another program from modifying part of a file that I am modifying?
Write a c program to demonstrate character and string constants?
Difference between constant pointer and pointer to a constant.
How do you determine a file’s attributes?
Write a code on reverse string and its complexity.
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.
What is void main ()?
Explain what is the purpose of "extern" keyword in a function declaration?
How do you do dynamic memory allocation in C applications?
Differentiate between declaring a variable and defining a variable?
which of the following is allowed in a "C" arithematic instruction a) [] b) {} c) () d) none of the above
What is methods in c?