Questions

Q:

How would you use qsort() function to sort an array of structures?

Answer

#include "string.h"


#include "stdlib.h"


struct stud


{


       int rollno;


       int marks;


       char name[30];


};


int sort_m (struct stud *, struct stud *);


int sort_name (struct stud *, struct stud *);


int sort_marks (struct stud *, struct stud *);


 


main()


{


static struct stud ss[] = {


                                            { 15, 96, "Akshay" },


                                            { 2, 97, "Madhuri" },


                                            { 8, 85, "Aishvarya" },


                                            { 10, 80, "Sushmita" }


                                   };


int x,w;


clrscr();


w = sizeof (struct stud);


 


printf ('\nIn order of roll numbers:");


qsort (ss, 4, w, sort_rn);


for(x=0; x<4;x++)


     printf ("\n%d%s%d", ss[x].rollno, ss[x].name,ss[x].marks);


 


printf("\n\nIn order of names:");


qsort(ss, 4, sort_name);


 


for (x=0; x<4;x++)


      printf("\n%d%s%d",ss[x].rollno, ss[x].name,ss[x].marks);


printf("\n\nIn order of marks:");


qsort(ss,4,w,sort_marks);


 


for (x=0;x<4;x++)


      printf ("\n%d%s%d",ss[x].rollno,ss[x].name,ss[x].marks);


}


int sort_rn (struct stud *t1, struct stud *t2)


{


     return (t1->rollno-t2->rollno);


}


 


int sort_name (struct stud *t1, struct stud *t2)


{


     return (strcmp(t1->name,t2->name));


}


int sort_marks (struct stud *t1, struct stud *t2)


{


     return (t2->marks-t1->marks);


}


 


 


 

Report Error

View answer Workspace Report Error Discuss

Subject: Programming

0 4089
Q:

Which interrupts is not level-sensitive in 8085?

Answer

TST 7.5 is a raising edge-triggering interrupt.

Report Error

View answer Workspace Report Error Discuss

Subject: Hardware

2 4088
Q:

A bond formed by the transfer of electrons between atoms of the elements is called

A) Ionic bond B) Covalent bond
C) Co-ordinate bond D) Hydrogen bond
 
Answer & Explanation Answer: A) Ionic bond

Explanation:
Report Error

View Answer Report Error Discuss

Filed Under: Chemistry

5 4087
Q:

A nuclear reactor is said to have become 'critical' when 

A) it stops due to malfunctioning B) it starts emitting dangerous radioactive radiations
C) it is shut down to avoid explosion D) it is ready to produce controlled energy
 
Answer & Explanation Answer: D) it is ready to produce controlled energy

Explanation:

To produce controlled energy i.e energy at a controlled or steady rate, the number of fissions per second must be controlled and maintained at that rate. Excess neutrons should be absorbed by control roads like cadmium.

Report Error

View Answer Report Error Discuss

Filed Under: Physics

4 4085
Q:

I have four fingers and a thumb, but not alive.

Who am I?

Answer

A glove. It has 5 fingers as we have but not alive.

Report Error

View answer Workspace Report Error Discuss

Subject: Logic Puzzles Exam Prep: GATE , CAT , Bank Exams , AIEEE
Job Role: Bank PO , Bank Clerk , Analyst

2 4083
Q:

Number of moles of solute present in 1 litre of solution is

A) Normality B) Molarity
C) Molality D) Formality
 
Answer & Explanation Answer: B) Molarity

Explanation:

Moles of solute present in 1 litre or 1000ml of solution is called molarity

Report Error

View Answer Report Error Discuss

Filed Under: Chemistry

5 4082
Q:

What is at the end of a rainbow?

Answer

The logical answer for a puzzle is that the letter 'W'.


 


A rainbow is a spectrum of light that appears in the sky when sunlight is refracted through raindrops or other drops of moisture in the Earth's atmosphere. They have inspired much popular folklore, including the belief that a leprechaun can be found with a pot of gold at the end of a rainbow.

Report Error

View answer Workspace Report Error Discuss

3 4081
Q:

The largest producer of fruits in the Anglo-American Region is _____

A) New - England Region B) Greak Lakes Region
C) California D) Application Region
 
Answer & Explanation Answer: C) California

Explanation:
Report Error

View Answer Report Error Discuss

Filed Under: World Geography

0 4080