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
‘ C’ PROGRAME TO SHOW THE TYPE OF TRANGLE BY ACCEPTING IT’S LENGTH .
Do variables need to be initialized?
Describe the order of precedence with regards to operators in C.
What is the correct declaration of main?
What does c mean in standard form?
What is #define in c?
How do shell structures work?
What is function in c with example?
Write a client and server program in C language using UDP, where client program interact with the Server as given below: i) The client begins by sending a request to send a string of 8 characters or series of 7 numbers, the server sends back a characters or numbers as per the request of the client. ii) In case of series of 7 numbers: The client sends a multiplication of numbers, to the server. iii) In case of a string of 8 characters: The client sends a reverse order of string to the server.. iv) Server will send an acknowledgment to the client after receiving the correct answer
Can you explain the four storage classes in C?
Which is an example of a structural homology?
Differentiate fundamental data types and derived data types in C.
What is huge pointer in c?
What is the difference between if else and switchstatement
how to find binary of number?