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

What makes an election democratic?

A) Elections should be held at regular intervals. B) The candidate preferred by the people should get elected.
C) Every citizen should have one vote ad every vote should have an equal value. D) All the above
 
Answer & Explanation Answer: D) All the above

Explanation:

In short, Democracy is a government "of the people, by the people, and for the people."

 

Definition :

Democracy "is government by the people in which the supreme power is vested in the people and exercised directly by them or by their elected agents under a free electoral system." 


The conditions of a democratic election are:

 

* Every citizen should have one vote ad every vote should have an equal value.

* Voters choose from the political parties and candidates should be free to contest elections giving the voters a real choice.

* Elections should be held at regular intervals.

* The candidate preferred by the people should get elected.

* Elections should be conducted in free and fair manner where people can choose as they really wish.

Report Error

View Answer Report Error Discuss

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

2 4150
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 4149
Q:

Which Bank has launched 'Project Nishchay' in partnership with The Boston Consulting Group (BCG) ?

A) SBI B) Dena Bank
C) IDBI Bank D) Yes Bank
 
Answer & Explanation Answer: C) IDBI Bank

Explanation:

IDBI Bank has launched 'Project Nishchay' in partnership with The Boston Consulting Group (BCG) to accelerate its turnaround programme and improve financial performance.

Report Error

View Answer Report Error Discuss

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

9 4147
Q:

Which is longest railway station ?

Answer

Grand Central Terminal, Chicago(USA).

Report Error

View answer Workspace Report Error Discuss

15 4147
Q:

Who Invented The World Wide Web ?

A) Sir Timothy John B) Earle Dickson
C) James Rineose D) Laszlo Jozsef Biro
 
Answer & Explanation Answer: A) Sir Timothy John

Explanation:
Report Error

View Answer Report Error Discuss

Filed Under: Inventions

0 4146
Q:

The world's tallest twisted tower is ?

A) Tokyo Sky Tree B) BREN Tower
C) Burj Khalifa D) Infinity Tower
 
Answer & Explanation Answer: D) Infinity Tower

Explanation:

The world's tallest twisted tower, the Infinity Tower was launched in Dubai Marina on 10 June 2013.

Report Error

View Answer Report Error Discuss

Filed Under: Famous Places
Exam Prep: AIEEE , Bank Exams , CAT
Job Role: Bank PO

5 4145
Q:

The famous song ‘Saare Jaha se Achha’ is composed by ___________

A) Ravindra Nath Tagore B) Bankim Chandra Chattopadhya
C) Mohammad Iqbal D) one of the above
 
Answer & Explanation Answer: C) Mohammad Iqbal

Explanation:
Report Error

View Answer Report Error Discuss

Filed Under: Indian Culture

53 4144