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 4284
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:

The largest producer of fruits in the Anglo-American Region is _____

A) New - England Region B) Greak Lakes Region
C) California D) Application Region
 
Answer & Explanation Answer: C) California

Explanation:
Report Error

View Answer Report Error Discuss

Filed Under: World Geography

0 4283
Q:

 Which JDBC driver Type(s) is(are) the JDBC-ODBC bridge?

A) Type 1 B) Type 2
C) Type 3 D) Type 4
 
Answer & Explanation Answer: A) Type 1

Explanation:
Report Error

View Answer Report Error Discuss

Filed Under: Database

0 4283
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 4282
Q:

India has been ranked ___ in terms of competitiveness in the annual rankings compiled by Institute for Management Development.

A) 45th B) 145th
C) 107th D) 56th
 
Answer & Explanation Answer: A) 45th

Explanation:

India has been ranked 45th, down four notches from last year, in terms of competitiveness in the annual rankings compiled by IMD which saw Hong Kong topping the list. US was “pushed out” of the top three slots while Hong Kong consolidated its dominance of the annual rankings for the second year in the list compiled by the International Institute for Management Development’s (IMD) World Competitiveness Center.

Report Error

View Answer Report Error Discuss

Filed Under: Indian Economy

14 4278
Q:

Name the malicious software that affected various computers recently in may 2017, and restricted users to access it until a ransom is paid to unlock it  ?

A) Bitcoinware B) Captiveware
C) Pay-offware D) Ransomware
 
Answer & Explanation Answer: D) Ransomware

Explanation:
Report Error

View Answer Report Error Discuss

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

2 4277
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 4275