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

A research team of 6 people is to be formed from 10 chemists,5 politicians, 8 economists and 15 biologists.How many teams have atleast 5 chemists?

A) 7350 B) 6400
C) 6379 D) 7266
 
Answer & Explanation Answer: D) 7266

Explanation:

10C5 x 28C1 x 10C6 = 7266

Report Error

View Answer Report Error Discuss

0 4281
Q:

RADAR is used for

A) detecting and locating the position of objects such as Aeroplanes B) locating submerged submarines
C) locating geostationary satellites D) receiving a signals in a radio receiver
 
Answer & Explanation Answer: A) detecting and locating the position of objects such as Aeroplanes

Explanation:

RADAR - RAdio Detection And Ranging.

A radar system consists of a transmitter producing electromagnetic waves in the radio or microwaves domain, a transmitting antenna, a receiving antenna (often the same antenna is used for transmitting and receiving) and a receiver and processor to determine properties of the objects. 

 

Radar is an object-detection system that uses radio waves to determine the range, angle, or velocity of objects. It can be used to detect aircraft, ships, spacecraft, guided missiles, motor vehicles, weather formations, and terrain.

 

Radio waves from the transmitter reflect off the object and return to the receiver, giving information about the object's location and speed.

Report Error

View Answer Report Error Discuss

Filed Under: Physics
Exam Prep: GATE , CAT , Bank Exams , AIEEE
Job Role: Network Engineer , IT Trainer , Bank PO , Bank Clerk , Analyst

5 4281
Q:

Who was Mihirakula?

A) An Indo-Greek ruler B) A Huna invader
C) A chinese pilgrim D) A Saka ruler
 
Answer & Explanation Answer: B) A Huna invader

Explanation:

Mihirakula, also Mahiragula, was one of the most important rulers of the Alchon Huns, who led a conquest and gained temporary control of Gandhara, Kashmir, northern and central India. Mihirakula was a son of Toramana, both of Huna heritage, and ruled the Indian part of the Hephthalite Empire.

Report Error

View Answer Report Error Discuss

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

2 4280
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 4280
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 4279
Q:

Clay is an example of

A) Aquiclude B) Glossy
C) Utilitarian D) None of the above
 
Answer & Explanation Answer: A) Aquiclude

Explanation:

Clay is an example of Aquiclude.

Report Error

View Answer Report Error Discuss

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

0 4279
Q:

Who gave the slogan Bharat Chhodo during the Quit India movement?

A) Gandhi B) Yusuf Meher Ali
C) Nehru D) Aruna Asif Ali
 
Answer & Explanation Answer: A) Gandhi

Explanation:

Mohandas Karamchand Gandhi gave the slogan Bharat Chhodo during the Quit India movement.

Report Error

View Answer Report Error Discuss

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

20 4278