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

What is the assigned code name of India first nuclear explosion at Pokran ?  

A) Operation Sakshi B) Operation Hurricane
C) Operation smiling Buddha D) Operation cross road
 
Answer & Explanation Answer: C) Operation smiling Buddha

Explanation:
Report Error

View Answer Report Error Discuss

Filed Under: General Awareness

3 4283
Q:

An important tool for project scope management is

A) Fast tracking B) Work breakdown structure
C) Crashing D) A Gantt Chart
 
Answer & Explanation Answer: B) Work breakdown structure

Explanation:

Work breakdown structure is an important tool for project scope management.

 

Project Scope Management refers to the set of processes that ensure a project’s scope is accurately defined and mapped. Scope Management techniques enable project managers and supervisors to allocate just the right amount of work necessary to successfully complete a project—concerned primarily with controlling what is and what is not part of the project’s scope.

Report Error

View Answer Report Error Discuss

14 4282
Q:

Whenever people are looking for a job, they frequently see "program manager wanted" and "project manager wanted" when reading the job listings in their local newspaper. Which of the following statements best describes the relationship between projects and programs?

A) There are no differences between the two;they are just different terms for the same thing B) A project is composed of one or more related programs.
C) A program is composed of one or more related projects. D) A project is a temporary endeavor, where as a program is permanent
 
Answer & Explanation Answer: C) A program is composed of one or more related projects.

Explanation:

Answer A is incorrect because there is a definite difference between the two terms. Answer B is incorrect because just the opposite is true. Answer D is incorrect because a program is a group of projects, which are temporary endeavors.

Report Error

View Answer Report Error Discuss

Filed Under: PMP Certification

0 4281
Q:

Which method of expressing direction is indicated in the illustration?

A) Section B) Interjuction
C) Intersection D) None of the above
 
Answer & Explanation Answer: C) Intersection

Explanation:

Which_method_of_expressing_direction_is_indicated_in_the_illustration1556259373.png image

 

Intersection method of expressing direction is indicated in the illustration.

Report Error

View Answer Report Error Discuss

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

5 4281
Q:

Garba a popular folk dance is associated with Indian state

Answer

Gujarat

Report Error

View answer Workspace Report Error Discuss

Subject: Indian Culture

53 4281
Q:

 Which JDBC driver Type(s) is(are) the JDBC-ODBC bridge?

A) Type 1 B) Type 2
C) Type 3 D) Type 4
 
Answer & Explanation Answer: A) Type 1

Explanation:
Report Error

View Answer Report Error Discuss

Filed Under: Database

0 4280
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 4280