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 the difference between text and binary i/o?
how is the examination pattern?
in iso what are the common technological language?
How do you define a string?
Which programming language is best for getting job 2020?
What is a c token and types of c tokens?
What the different types of arrays in c?
How can this be legal c?
What is difference between structure and union?
What is the difference between malloc() and calloc()?
Is c weakly typed?
Create a structure to specify data on students as given below: Roll number, Name, Department, Course, and Year of joining. Assume that there are not more than 450 students in the collage. (a) Write a function to print the names of all students who joined in the last 3 years. (b) Write a function to print the data of a student whose roll numbers are divisible by 4.
How do I use void main?
How can I access an I o board directly?
What is the difference between union and structure in c?