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 is a dynamic array in c?
What is class and object in c?
What is the purpose of scanf() and printf() functions?
PLS U SENS ME INTERVIEW O. MY EMAIL ADD, SOFIYA.SINGH@GMAIL.COM
Write a program to identify if a given binary tree is balanced or not.
How can I invoke another program (a standalone executable, or an operating system command) from within a c program?
Is it fine to write void main () or main () in c?
What does *p++ do? What does it point to?
What does %c mean in c?
What does s c mean on snapchat?
Why doesn't C support function overloading?
What are the modifiers available in c programming language?
How do you declare a variable that will hold string values?
What is adt in c programming?
What is the difference between class and object in c?