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
What are the benefits of c language?
What is an auto keyword in c?
what is the difference between class and unio?
What is the benefit of using #define to declare a constant?
What is the difference between a function and a method in c?
What is the scope of static variable in c?
What are derived data types in c?
What functions are used in dynamic memory allocation in c?
Why c is a mother language?
What is the explanation for the dangling pointer in c?
What does sizeof function do?
Explain how can you determine the size of an allocated portion of memory?
what are the facialities provided by you after the selection of the student.
I heard that you have to include stdio.h before calling printf. Why?
I need a help with a program: Write a C program that uses data input in determining the whole of points A and a whole of circles B. Find two points in A so that the line which passes through them, cut through the maximum number of circles.