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

Bose selected the best soldiers from the three existing brigades (named after Gandhi Azad and Nehru)and organised a new brigade which the soldiers themselves called

A) Himalayan Brigade B) Swatantra Bharat Brigade
C) Bhagat Singh Brigade D) Subhas Brigade
 
Answer & Explanation Answer: D) Subhas Brigade

Explanation:
Report Error

View Answer Report Error Discuss

Filed Under: Indian History

2 4142
Q:

Which Rating agency has projected India’s GDP growth rate to 6.9 percent for the financial year 2017-18 ?

A) NOMURA B) ONICRA
C) FITCH D) ICRA
 
Answer & Explanation Answer: C) FITCH

Explanation:
Report Error

View Answer Report Error Discuss

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

15 4142
Q:

Now my value becomes ?

value1499404917.jpg image

A) 5 B) 10
C) 15 D) 12
 
Answer & Explanation Answer: B) 10

Explanation:

In the first figure, number of triangles are 5.

In the second, the figure becomes double then the number of triangles also doubles.

i.e, 10. 

Report Error

View Answer Report Error Discuss

Filed Under: Logic Puzzles
Exam Prep: AIEEE , Bank Exams , CAT
Job Role: Bank Clerk

15 4140
Q:

What is Rank of India in World business optimism ranking?

A) 4th B) 6th
C) 5th D) 7th
 
Answer & Explanation Answer: D) 7th

Explanation:

India slips to 7th position on the business optimism ranking.

The results of Grant Thornton’s International Business Report (IBR), a quarterly global business survey, reveal that business optimism in India has slipped from 2nd position in the last quarter to 7th position in the 3rd quarter of 2017.

Report Error

View Answer Report Error Discuss

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

14 4139
Q:

Which city has been designated as the UNESCO World Book Capital 2019  ?

A) Warsaw B) Sharjah
C) Pune D) Kochi
 
Answer & Explanation Answer: B) Sharjah

Explanation:

Sharjah, the city of United Arab Emirates (UAE), has been designated as the UNESCO World Book Capital 2019 by Irina Bokova, the Director-General of UNESCO, at the Headquarters of the International Federation of Library Associations (IFLA) at La Haye. The honour is in recognition of the Emirate’s pioneering role in supporting and expanding the local and regional publishing industries, promoting reading to become an intrinsic cultural practice, as well as embracing inter-cultural, knowledge-based dialogue. Sharjah was the first emirate in UAE to establish a formal school and a library. It was also the first emirate to house many cultural institutions like the Emirates Publishers Association and the Emirates’ writers Union. Sharjah is the 19th city to become World Book Capital. It is preceded by Conakry in 2017 and Athens in 2018.

Report Error

View Answer Report Error Discuss

Filed Under: General Awareness

8 4139
Q:

What is CPC  ?

A) Central Person scheme B) Central Pay commission
C) Central Paid determination D) Central Pay scheme
 
Answer & Explanation Answer: B) Central Pay commission

Explanation:
Report Error

View Answer Report Error Discuss

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

6 4138