write a program to fined second smallest and largest element
in a given series of elements (without sorting)
Answer Posted / vadivel t
#include<stdio.h>
void main()
{
int a[10] = {5,4,1,7,3,0,8,23,12,24};
int Lcount = 0, Gcount = 0, i, j;
for(i = 0; i<10; i++)
{
Gcount = 0;
Lcount = 0;
for(j = 0; j<10; j++)
{
if(a[i] > a[j])
{
Gcount++;
Lcount++;
}
}
if(Gcount == 8)
{
printf("The second largest no is: %
d \n", a[i]);
}
if(Lcount == 1)
{
printf("The second smallest no is: %
d \n", a[i]);
}
}
_getch();
}
Is This Answer Correct ? | 2 Yes | 4 No |
Post New Answer View All Answers
Explain how can I read and write comma-delimited text?
design and implement a data structure and performs the following operation with the help of file (included 1000 student marks in 5 sub. and %also) 1.how many students are fail in all 5 subjects (if >35) 2. delete all student data those are fail in all 5 subjects. 3. update the grace marks (5 no. if exam paper is 100 marks) 4. arrange the student data in ascending order basis of marks. 5.insert double of deleted students with marks in the list.
What is c language and why we use it?
write a progrmm in c language take user interface generate table using for loop?
What is the size of a union variable?
What are 'near' and 'far' pointers?
What is the purpose of void pointer?
why to assign a pointer to null sometimes??how can a pointer we declare get assigned with a garbage value by default???
What is const volatile variable in c?
Tell me can the size of an array be declared at runtime?
write a c program to do the following: a) To find the area of a triangle. b) To convert the temperature from Fahrenheit to Celsius. c) To convert the time in hours : minutes : seconds to seconds.
What does int main () mean?
Differentiate between declaring a variable and defining a variable?
How to set file pointer to beginning c?
What is c programing language?