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

What has a mouth but never smiles?

Answer

A bottle has a mouth from which we used to drink water or any juice. But it cannot smile.

Report Error

View answer Workspace Report Error Discuss

Subject: Word Puzzles Exam Prep: TOEFL , GRE , GATE , CAT , Bank Exams , AIEEE
Job Role: Bank PO , Bank Clerk , Analyst

13 4131
Q:

The Indian to beat the computers in mathematical wizardry is

A) Shakuntala Devi B) Raja Ramanna
C) Rina Panigrahi D) Ramanujam
 
Answer & Explanation Answer: A) Shakuntala Devi

Explanation:
Report Error

View Answer Report Error Discuss

3 4129
Q:

Two identical solid pieces, one of gold and other of silver, when immersed completely in water exhibit equal weights. When weighed in air (given that density of gold is greater than that of silver)

A) the gold piece will weigh more B) the silver piece will weighmore
C) both silver and gold pieces weigh equal D) weighing will depend on their masses
 
Answer & Explanation Answer: B) the silver piece will weighmore

Explanation:

As it is said that density of gold is greater than that of density of silver, so silver occupies a greater volume than gold. So it has more upthrust from the water, although they both show the same weight under water, there is more silver present. Hence silver piece will weigh more.

Report Error

View Answer Report Error Discuss

Filed Under: Physics
Exam Prep: Bank Exams

0 4129
Q:

Managing advertising, sales promotion and public relations :

what is public relations in marketing?

Answer

Public relations includes promotional activities that work to create a strong public image of the company. Public relations activities include helping the public to understand the company and its products. Public relations if done right can reach a large audience without the expensive cost of traditional advertising and marketing.

Report Error

View answer Workspace Report Error Discuss

0 4128
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 4127
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 4125
Q:

One light year is approximately equal to

A) 10^12 mts B) 10^16 mts
C) 10^11 mts D) 10^13 mts
 
Answer & Explanation Answer: B) 10^16 mts

Explanation:

Light year is the unit of to express astronomical distances, that light can travel in one year. Light moves at a velocity of about 300,000 kilometers (km) each second. So in one year, it can travel about 10 trillion km. More precisely, one light-year is equal to 9,500,000,000,000 kilometers.

 

Approximately, 1 light year = 10^16 mts.

Report Error

View Answer Report Error Discuss

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

4 4123