write a program to fined second smallest and largest element
in a given series of elements (without sorting)
Answer Posted / raj
#include <stdio.h>
void main()
{
int i, ar[] ={15,22,122,15,6,12};
int a,b= 0,c,ta ,tb, tc;
a =ar[0];
b = ar[1];
for (i = 0; i < 6 ;i++)
{
if(a > ar[i])
{
b = a;
a = ar[i];
}
else if(b > ar[i])
{
b = ar[i];
}
}
printf("\n %d ",b);
}
| Is This Answer Correct ? | 3 Yes | 3 No |
Post New Answer View All Answers
What are the types of pointers?
What is optimization in c?
Can you subtract pointers from each other? Why would you?
How will you declare an array of three function pointers where each function receives two ints and returns a float?
how to write optimum code to divide a 50 digit number with a 25 digit number??
Are local variables initialized to zero by default in c?
How can I read data from data files with particular formats?
What are the advantages of using macro in c language?
Why is it important to memset a variable, immediately after allocating memory to it ?
How many types of functions are there in c?
What are the advantages and disadvantages of pointers?
How to declare pointer variables?
Why c language?
What is the difference between struct and union in C?
Can we declare variables anywhere in c?