write a program to fined second smallest and largest element
in a given series of elements (without sorting)
Answer Posted / nikhil kumar saraf
void main()
{
int a[12],max,min,min2,i;
printf("enter values");
for(i=0;i<10;i++)
scanf(%d,&a[i]);
max=a[0];
min=a[0];
for(i=0;i<10;i++)
{
if(max<a[i])
max=a[i];
if(min>a[i])
min=a[i];
}
min2=a[0];
for(i=0;i<10;i++)
{
if(min2>a[i] && a[i]!=min)
{
min2=a[i];
}
printf("The second smallest element is:-%d",min2);
printf("The largest element is:-%d",max);
getch();
}
| Is This Answer Correct ? | 2 Yes | 4 No |
Post New Answer View All Answers
How can this be legal c?
What is the total generic pointer type?
Explain how can I pad a string to a known length?
Is c language still used?
Explain the use of bit fieild.
Explain about the constants which help in debugging?
What is wrong with this declaration?
What are pointers in C? Give an example where to illustrate their significance.
What is Dynamic memory allocation in C? Name the dynamic allocation functions.
What are the types of data files?
write a c program to print the next of a particular no without using the arithmetic operator or looping statements?
What is else if ladder?
How to compare array with pointer in c?
What is unsigned int in c?
What is pointers in c with example?