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

Subject matters experts (SMEs) are resources that are imperative to the succes of a project. Many times, project managers are not experts in the areas they are managing and frequently must rely upon other's expertise. In which scope - management process are SMEs first used?

A) Scope planning B) Scope definition
C) Initiation D) Scope verification
 
Answer & Explanation Answer: C) Initiation

Explanation:

Initiation is the first step in the scope management process, and expert judgment is one of the techniques routinely utilized. Answers A, B, and D are incorrect because they would come after the initiation process.

Report Error

View Answer Report Error Discuss

Filed Under: PMP Certification

0 4137
Q:

The earth revolves around the Sun in an elliptical path and the sun is located at one focus of the ellipse. Imagine a situation in which the earth goes around the Sun on a circular path. Which one among the following would result in under that situation ?

A) It would not make any difference B) Difference between seasons will be reduced
C) The earth would become very hot D) The earth would become very cold
 
Answer & Explanation Answer: B) Difference between seasons will be reduced

Explanation:
Report Error

View Answer Report Error Discuss

Filed Under: World Geography

6 4136
Q:

Select the correct statement about the pharynx.

A) The auditory tube drains into the nasopharynx B) The laryngopharynx blends posteriorly into the nasopharynx
C) The palatine tonsils are embedded in the lateral walls of the nasopharynx D) The pharyngeal tonsil is located in the laryngopharynx
 
Answer & Explanation Answer: A) The auditory tube drains into the nasopharynx

Explanation:
Report Error

View Answer Report Error Discuss

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

3 4136
Q:

'Roaring Forties' are 

A) waterfalls in canada B) cyclonic winds
C) the turbulent years in world History from 1940 to 1944 D) westerly winds blowing through out the year over the oceans of the Southern Hemisphere between 40 degrees and 60 degrees south
 
Answer & Explanation Answer: D) westerly winds blowing through out the year over the oceans of the Southern Hemisphere between 40 degrees and 60 degrees south

Explanation:

The absence of a landmass within these latitudes in the southern hemisphere eliminate friction and lends force to these winds and hence derives the name

Report Error

View Answer Report Error Discuss

Filed Under: World Geography

0 4134
Q:

Hormones are chemicals secreted and regulated by the endocrine system.

A) TRUE B) FALSE
Answer & Explanation Answer: A) TRUE

Explanation:

True. Hormones are chemicals secreted and regulated by the endocrine system.

Report Error

View Answer Workspace Report Error Discuss

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

4 4133
Q:

World’s largest aircraft supercarrier USS Gerald R Ford belongs to _____ country.

A) Russia B) India
C) China D) USA
 
Answer & Explanation Answer: D) USA

Explanation:

1. US Navy commissioned world’s largest aircraft carrier, USS Gerald R Ford into the fleet. The commissioning ceremony was held at Naval Station Norfolk, Virginia in presence of US President Donald Trump.

2. USS Gerald R. Ford is the first ship in this new class of nuclear-powered aircraft carriers for the U.S. Navy. The ship is named after the 38th President of the United States Gerald Ford and has been built by Newport News Ship Building Company. The massive 1,106-foot-long carrier is powered by two new generation nuclear reactors.

Report Error

View Answer Report Error Discuss

Filed Under: General Awareness
Exam Prep: AIEEE , Bank Exams , CAT
Job Role: Bank Clerk , Bank PO

9 4133
Q:

India was partitioned as a consequence of the formula contained in 

A) Cabinet Mission Plan B) Attlee's Declaration
C) June 3 plan or Mountbatten plan D) Both (b) and (c)
 
Answer & Explanation Answer: C) June 3 plan or Mountbatten plan

Explanation:
Report Error

View Answer Report Error Discuss

Filed Under: Indian History

2 4132