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

Which is longest railway station ?

Answer

Grand Central Terminal, Chicago(USA).

Report Error

View answer Workspace Report Error Discuss

15 4144
Q:

What time of year do squirrels build nests?

A) Winter B) Summer
C) Rainy D) Monsoon
 
Answer & Explanation Answer: B) Summer

Explanation:

Squirrels typically build leaf nests in the summer by weaving together small branches they've gnawed off of trees. These nests are lined with grass, moss, leaves and pine needles. Both male and female gray squirrels of all ages participate in building dens.
 

Report Error

View Answer Report Error Discuss

Filed Under: Animals and Birds
Exam Prep: AIEEE , Bank Exams
Job Role: Analyst , Bank Clerk , Bank PO

12 4142
Q:

Acid Precipitation is caused by a mix of

A) Hydrogen, Oxygen, and Saline B) Water, Soil, and Air
C) Respiration, Carbonic Acids, and Seawater D) Sulfur Dioxide, Carbon Dioxide, Nitrogen Oxides
 
Answer & Explanation Answer: D) Sulfur Dioxide, Carbon Dioxide, Nitrogen Oxides

Explanation:

Acid Precipitation or Acid rain is caused by a mix of Sulfur Dioxide, Carbon Dioxide, Nitrogen Oxides.

 

A Chemical reaction that begins when compounds like sulfur dioxide and nitrogen oxides are released into the air. These substances can rise very high into the atmosphere, where they mix and react with water, oxygen, and other chemicals to form more acidic pollutants, known as Acid Rains.

Report Error

View Answer Report Error Discuss

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

6 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:

First Indian woman, to win The silver medal in Rio Olympics 2016 ?

A) Sakshi Malik B) P V Sindhu
C) Dipa Karmakar D) Saina Nehwal
 
Answer & Explanation Answer: B) P V Sindhu

Explanation:
Report Error

View Answer Report Error Discuss

Filed Under: Sports

6 4141
Q:

The process of encoding refers to

A) getting information into memory. B) the recall of information previously learned.
C) a clear memory of an emotionally significant event. D) the persistence of learning over time.
 
Answer & Explanation Answer: A) getting information into memory.

Explanation:

Encoding refers to the getting information into memory.

Report Error

View Answer Report Error Discuss

6 4141
Q:

The term Upari refers to which one of the following?

A) A category of proprietary tenure under the Mughal rule B) A category of tenancy tenure under the Maratha rule
C) A soldier in the Maratha army D) A village headman in the Mughal period.
 
Answer & Explanation Answer: B) A category of tenancy tenure under the Maratha rule

Explanation:

Upari refers to a category of tenancy tenure held under the Maratha Regime.The Government used to assign land to various cultivators for cultivation and getting maximum revenue. The land allotted to original settlers of villages came to be known as Mirasi land whereas the land assigned to the migrant settlers was known as the Upari land.

 

Report Error

View Answer Report Error Discuss

Filed Under: General Awareness
Exam Prep: Bank Exams

0 4140