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
Describe newline escape sequence with a sample program?
When would you use a pointer to a function?
write a programe to accept any two number and check the following condition using goto state ment.if a>b,print a & find whether it is even or odd and then print.and a
How can you allocate arrays or structures bigger than 64K?
What does char * * argv mean in c?
What is scanf_s in c?
write a program to concatenation the string using switch case?
What are valid signatures for the Main function?
Write an algorithm for implementing insertion and deletion operations in a singly linked list using arrays ?
What is #include conio h?
Why do we write return 0 in c?
Explain how to reverse singly link list.
What are the basic data types associated with c?
What is pointer to pointer in c with example?
Difference between exit() and _exit() function?