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

The software development life cycle begins with a proof of concept and progress into the build, test, and acceptance phases as the project develops. Some times, differences between stakeholders can develop into conflict, which impacts the customer. As a trained, professional project manager, how do you handle this situation and resolve the customer's concerns?

A) Let the customer vent and take notes B) Schedule a meeting
C) Develope a change request for the customer D) Resolve the matter in favour of the customer
 
Answer & Explanation Answer: D) Resolve the matter in favour of the customer

Explanation:
Report Error

View Answer Report Error Discuss

Filed Under: PMP Certification

0 4444
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 4443
Q:

The amount of RAM storage is measured in

A) bytes B) mega bytes
C) giga bytes D) All of the above
 
Answer & Explanation Answer: D) All of the above

Explanation:

RAM storage capacity is measured in bytes, kilo bytes, mega bytes, giga bytes,...

Report Error

View Answer Report Error Discuss

2 4443
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 4442
Q:

Which command displays the present workig directory in UNIX?

A) $who B) $pwd
C) $who are you D) None
 
Answer & Explanation Answer: B) $pwd

Explanation:

$pwd - present working directory

Report Error

View Answer Report Error Discuss

Filed Under: Operating Systems

0 4442
Q:

 What item, originally called the ‘Whirlwind’, was invented by Ives McGaffey in 1869?

A) Blender B) Electric mixer
C) Washing machine D) Vacuum cleaner
 
Answer & Explanation Answer: B) Electric mixer

Explanation:
Report Error

View Answer Report Error Discuss

Filed Under: Inventions

2 4441
Q:

Diamond is harder than Graphite because of

A) tetrahedral structure of diamond B) difference of crystalline structures
C) difference of layers of atoms D) hexagonal structure of graphite
 
Answer & Explanation Answer: B) difference of crystalline structures

Explanation:

Here are the differences between Diamond and Graphite :

 

diamond_is_harder_than_graphite_because_of1557300898.jpg image

 

From the above analysis, Diamond is harder than Graphite because of the difference of crystalline structures.

Report Error

View Answer Report Error Discuss

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

3 4441