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 4144
Q:

Modem is used mostly for ?

A) A modern empty memory modules B) Connecting to internet
C) Mostly for file system D) All the above
 
Answer & Explanation Answer: B) Connecting to internet

Explanation:

A modem is nothing but short for Modulator and Demodulator. It is used mostly for connecting to the internet.

A modem is a device or program that enables a computer to transmit data over, for example, telephone or cable lines. Computer information is stored digitally, whereas information transmitted over telephone lines is transmitted in the form of analog waves.

 

Report Error

View Answer Report Error Discuss

Filed Under: Physics
Exam Prep: AIEEE , Bank Exams , GATE
Job Role: Analyst , Bank Clerk , Bank PO

4 4143
Q:

Which is longest railway station ?

Answer

Grand Central Terminal, Chicago(USA).

Report Error

View answer Workspace Report Error Discuss

15 4142
Q:

The famous song ‘Saare Jaha se Achha’ is composed by ___________

A) Ravindra Nath Tagore B) Bankim Chandra Chattopadhya
C) Mohammad Iqbal D) one of the above
 
Answer & Explanation Answer: C) Mohammad Iqbal

Explanation:
Report Error

View Answer Report Error Discuss

Filed Under: Indian Culture

53 4141
Q:

Which of the following organs of the United Nations Organisation elects judges of the International court of Justice

A) The economic and social council B) The security council and the General Assembly
C) The trusteeship council and the economic and social council D) The security council
 
Answer & Explanation Answer: B) The security council and the General Assembly

Explanation:
Report Error

View Answer Report Error Discuss

Filed Under: World Organisations

3 4140
Q:

Systems running more than one process concurrently are called ______________

A) Multiprocessing B) Multiprogramming
C) Real time D) Batch processing
 
Answer & Explanation Answer: B) Multiprogramming

Explanation:
Report Error

View Answer Report Error Discuss

Filed Under: Computer
Exam Prep: Bank Exams

5 4138
Q:

Localized area of pus formation in the lungs is

A) Pulmonary embolism B) Pulmonary abscess
C) Pleurisy D) Pulmonary edema
 
Answer & Explanation Answer: B) Pulmonary abscess

Explanation:

Pulmonary abscess is a type of liquefactive necrosis of the lung tissue. 

 

 localized_area_of_pus_formation_in_the_lungs1537941339.jpg image

 

Hence, Localized area of pus formation in the lungs is Pulmonary abscess.

Report Error

View Answer Report Error Discuss

Filed Under: Biology
Exam Prep: Bank Exams , AIEEE
Job Role: Bank PO , Bank Clerk , Analyst

4 4138
Q:

I shrink smaller every time I take a bath.

What am I ?

Answer

A Soap.


Yes, it gets shrinks smaller every time we take a bath.

Report Error

View answer Workspace Report Error Discuss

2 4137