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

First Indian woman, to win The silver medal in Rio Olympics 2016 ?

A) Sakshi Malik B) P V Sindhu
C) Dipa Karmakar D) Saina Nehwal
 
Answer & Explanation Answer: B) P V Sindhu

Explanation:
Report Error

View Answer Report Error Discuss

Filed Under: Sports

6 4287
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 4286
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 4285
Q:

Electric current is measured by which instrument?

A) voltmeter B) ammeter
C) barometer D) sinometer
 
Answer & Explanation Answer: B) ammeter

Explanation:

Electric current is measured by the instrument called ammeter. As current in a circuit is measured in amperes, the instrument used is called as ammeter.

Electric_current_is_measured_by_which_instrument1555505098.jpg image

Report Error

View Answer Report Error Discuss

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

3 4285
Q:

The study of the weather is known as

A) Weatherology B) Siesmology
C) Meteorology D) Pulmology
 
Answer & Explanation Answer: C) Meteorology

Explanation:

Meteorology is the study of weather and Earth's atmosphere. Climatology is another term used to describe the study of weather.

 

Studying the weather is not only useful for determining if you'll need an umbrella for the day. While forecasting is an important aspect of studying weather, understanding weather patterns provides valuable information about the status of the planet.

Report Error

View Answer Report Error Discuss

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

1 4283
Q:

Which is the official language of Central Bank of West African Bank

A) French B) Arabic
C) English D) Hindi
 
Answer & Explanation Answer: A) French

Explanation:
Report Error

View Answer Report Error Discuss

Filed Under: World Organisations

3 4283
Q:

Solve this Math puzzle?

math_number_puzzle1538999808.jpg image

A) 96 B) 88
C) 40 D) 19
 
Answer & Explanation Answer: A) 96

Explanation:

The given math puzzle follows a logic that,

1 + 4 = 5 => 1 x 4 + 1 = 5

2 + 5 = 12 => 2 x 5 + 2 = 12

3 + 6 = 21 => 3 x 6 + 3 = 21

 

Similarly,

8 + 11 = > 8 x 11 + 8 = 96.

Report Error

View Answer Report Error Discuss

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

9 4282