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

The type of fracture where bone is broken at several places

A) Complicated fracture B) Green stick fracture
C) Impact fracture D) Comminuted fracture
 
Answer & Explanation Answer: D) Comminuted fracture

Explanation:
Report Error

View Answer Report Error Discuss

Filed Under: Biology

8 4128
Q:

The richest source of Vitamin D from food is

A) Cotton seed oil B) Olive oil
C) Cod liver oil D) Sunflower oil
 
Answer & Explanation Answer: C) Cod liver oil

Explanation:
Report Error

View Answer Report Error Discuss

Filed Under: Biology
Exam Prep: AIEEE , Bank Exams

23 4126
Q:

Seagate is manufacturer of

A) harddisk B) earth moving equipment
C) picture tube D) banking software
 
Answer & Explanation Answer: A) harddisk

Explanation:
Report Error

View Answer Report Error Discuss

Filed Under: Business Awareness

14 4126
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 4126
Q:

Which company received top honors at the 2017 Frost & Sullivan India Digital Transformation Awards  ?

A) Spice Communications B) Reliance Communications
C) Brocade Communications D) Tata Communications
 
Answer & Explanation Answer: D) Tata Communications

Explanation:

At 2017 Frost & Sullivan India Digital Transformation Awards. Tata Communications received top honors at the 2017 Frost & Sullivan India Digital Transformation Awards, with four awards in the Enterprise Telecom Services category and one award in the Enterprise Infrastructure category. T ata Communications took centerstage at the awards ceremony and received four Service Provider of the Year awards for: (1) Enterprise Data (2) Hosted Contact Center (3) Enterprise Telecom – Large Enterprise Segment, and (4) Third Party Datacenter. It also won New Product/Service Innovation Award for IoT – a new award category this year.

Report Error

View Answer Report Error Discuss

Filed Under: General Awareness

3 4124
Q:

What is the theme of 2017 World Environment Day (WED)  ?

A) Connecting People to Nature B) Raise Your Voice Not The Sea Level
C) Think.Eat.Save D) Green Economy: Does it include you?
 
Answer & Explanation Answer: A) Connecting People to Nature

Explanation:

The World Environment Day (WED) is observed every year on June 5 to raise awareness about forests and wider issues of environmental protection. The 2017 theme is ‘Connecting People to Nature’. It implores us to get outdoors and into nature, to appreciate its beauty and to take forward the call to protect the Earth that we share. The host country for the WED 2017 is Canada, where the official celebrations take place.

Report Error

View Answer Report Error Discuss

Filed Under: Important Days and Years
Exam Prep: AIEEE , Bank Exams , CAT

4 4123
Q:

Solids have definite shapes.This is because

A) the forces of cohesion of the molecules within are very much less in them B) the forces of cohesion are very large
C) the forces of adhesion are large D) the forces of adhesion are less
 
Answer & Explanation Answer: B) the forces of cohesion are very large

Explanation:

Cohesion refers to attraction between molecules of the same kind while adhesion refers to attraction between different kinds of molecules

Report Error

View Answer Report Error Discuss

Filed Under: Physics

3 4122