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

In the given question, a statement divided into different segments is given. The first segment is fixed, rearrange the other segments to form a coherent statement.

It was hard for the Afghans/ leading to the subtle plummeting of the morale (P)/ to withstand the wave after wave of enemy attacks (Q)/ their plight further worsened the situation (R)/ and the indifference of the allies towards (S)

A) QSRP B) PQRS
C) RQPS D) SRPQ
 
Answer & Explanation Answer: A) QSRP

Explanation:

Clearly, only segment Q fits after the first segment. This eliminates all the options except 1.

Option 2: It is incorrect because it ends in S which ends in 'towards' which can't be used to any statement.

Option 3: It is incorrect for the same reason as option 2.

Option 4: 'towards their plight further worsened' makes no sense; hence it can be eliminated.

Option 5: R is a clear misfit after the first segment; hence it can also be eliminated. Hence, the correct sequence is QSRP.

Report Error

View Answer Report Error Discuss

Filed Under: English

0 4242
Q:

Nobel Prize is established in  ?

A) 1931 B) 1911
C) 1901 D) 1951
 
Answer & Explanation Answer: C) 1901

Explanation:
Report Error

View Answer Report Error Discuss

Filed Under: General Science
Exam Prep: CAT , Bank Exams

8 4242
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 4241
Q:

What is Rank of India in World business optimism ranking?

A) 4th B) 6th
C) 5th D) 7th
 
Answer & Explanation Answer: D) 7th

Explanation:

India slips to 7th position on the business optimism ranking.

The results of Grant Thornton’s International Business Report (IBR), a quarterly global business survey, reveal that business optimism in India has slipped from 2nd position in the last quarter to 7th position in the 3rd quarter of 2017.

Report Error

View Answer Report Error Discuss

Filed Under: Indian Economy
Exam Prep: Bank Exams , CAT
Job Role: Bank Clerk

14 4241
Q:

The type of fracture where bone is broken at several places

A) Complicated fracture B) Green stick fracture
C) Impact fracture D) Comminuted fracture
 
Answer & Explanation Answer: D) Comminuted fracture

Explanation:
Report Error

View Answer Report Error Discuss

Filed Under: Biology

8 4240
Q:

Which of the following is an example of representative money?

A) Salt B) A tract of land
C) Gold D) A check
 
Answer & Explanation Answer: D) A check

Explanation:

Representative money is an item such as a token or piece of paper that has no intrinsic value but can be exchanged on demand for a commodity that does have intrinsic value, such as gold, silver, copper,...

 

Hence, a Check is an example of representative money.

Report Error

View Answer Report Error Discuss

Filed Under: Indian Economy
Exam Prep: AIEEE , Bank Exams , CAT
Job Role: Analyst , Bank Clerk , Bank PO

9 4239
Q:

The NADPH required for the calvin cycle comes from

A) Reactions initiated in photosystem 1 B) Citric acid cycle
C) Reactions initiated in photosystem 2 D) Glycolysis
 
Answer & Explanation Answer: C) Reactions initiated in photosystem 2

Explanation:

ATP and NADPH produced by the light reactions are used in the Calvin cycle to reduce carbon dioxide to sugar. The Calvin cycle is similar to the Krebs cycle in that the starting material is regenerated by the end of the cycle.

Report Error

View Answer Report Error Discuss

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

5 4238