write a program to fined second smallest and largest element
in a given series of elements (without sorting)
Answer Posted / sachin tyagi
void main()
{
int a[12],max,min1.min2,max2,i,temp;
printf("enter valu");
for(i=0;i<11;i++)
scanf(%d,&a[i]);
max=a[0];
min1=a[0];
for(i=1;i<11;i++)
{
if(max<a[i])
max=a[i];
if(min1>a[i];
min1=a[i]
}
for(i=1;i<11;i++0
{
if((max2>a[i])&&(max2!=max){
max2=a[i];
}
if((min2<a[i])&&(min2!=min1))
{
min2=a[i];}
print("small is %d and large is %d", min2,max2);
}
Is This Answer Correct ? | 15 Yes | 13 No |
Post New Answer View All Answers
What is the use of a semicolon (;) at the end of every program statement?
Why doesnt this code work?
What is cohesion and coupling in c?
Explain what math functions are available for integers? For floating point?
Which of these functions is safer to use : fgets(), gets()? Why?
Explain how do you determine a file’s attributes?
7-Given an index k, return the kth row of the Pascal's triangle. For example, when k = 3, the row is [1,3,3,1]. For reference look at the following standard pascal’s triangle.
What is the use of define in c?
What are 'near' and 'far' pointers?
What are keywords c?
how can I convert a string to a number?
What are the string functions? List some string functions available in c.
What is operator promotion?
Ow can I insert or delete a line (or record) in the middle of a file?
When should you use a type cast?