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

Who has been selected for the prestigious 2016 Jnanpith Award ?

A) Ravuri Bharadwaja B) Shankha Ghosh
C) Kedarnath Singh D) Chandrashekara Kambara
 
Answer & Explanation Answer: B) Shankha Ghosh

Explanation:

Shankha Ghosh, the outstanding Bengali writer, commentator and academician, has been chosen for the prestigious 52nd version of the Jnanpith Award (2016) by the Government of India (GoI) for his lovely phrase and tries different things with different beautiful structures check his significance as an imaginative ability.The Jnanpith Award is presented every year to a literary figure for their outstanding contribution in literature. The honor conveys a reference, prize cash of Rs. 12 lakh and a bronze imitation of Goddess Saraswati.He turned into the sixth Bengali creator to win India's most astounding artistic honor after Mahasweta Devi, Tarashankar Bandopadhyay, Ashapurna Devi, Subhash Mukhopadhyay and Bishnu Dey.

Report Error

View Answer Report Error Discuss

Filed Under: Famous Personalities
Exam Prep: Bank Exams
Job Role: Bank Clerk

12 3882
Q:

6 B in an O?

A) 6 books in an order B) 6 balls in an over
C) 6 bats in an odd D) None of the above
 
Answer & Explanation Answer: B) 6 balls in an over

Explanation:

6 b in an o means 6 balls in an over in cricket.

Report Error

View Answer Report Error Discuss

4 3882
Q:

The India Parliament should meet at least ______.

 

A) Once a year B) Twice a year
C) Thrice a year D) Four times in a year
 
Answer & Explanation Answer: B) Twice a year

Explanation:
Report Error

View Answer Report Error Discuss

Filed Under: Indian Politics
Exam Prep: Bank Exams

0 3882
Q:

Highest Bridge in the world

A) Millau Viaduct B) Sidu River Bridge
C) Bailey Bridge D) None
 
Answer & Explanation Answer: C) Bailey Bridge

Explanation:

The Highest bridge in the world is Bailey bridge. It is located in the Ladakh valley between Dras and Suru rivers in the Himalayan mountains. It was built by the Indian Army in August 1982.

It is 30 meters (98 ft) long and is at an altitude of 5,602 meters (18,379 ft) above sea level.

Report Error

View Answer Report Error Discuss

Filed Under: Longest, Shortest, Deepest
Exam Prep: AIEEE , Bank Exams , CAT , GATE
Job Role: Bank Clerk , Bank PO

16 3881
Q:

Which pair is not correctly matched

A) Mahadevi Verma - Megsaysay award B) Indira Gandhi - UN population award
C) Mother Teresa - Magsaysay award D) S. Chandrashekhar - Nobel Prize
 
Answer & Explanation Answer: A) Mahadevi Verma - Megsaysay award

Explanation:
Report Error

View Answer Report Error Discuss

Filed Under: Honours and Awards

2 3881
Q:

Which of the following is/are the function(s) of bile juice released from the liver?

 

I. Make the food coming from stomach alkaline.

II. Conversion of proteins into amino acids.

III. Break down of fats into smaller globules.

 

A) Only I   B) Only II and III  
C) Only I and III   D) All I, II and III  
 
Answer & Explanation Answer: C) Only I and III  

Explanation:
Report Error

View Answer Report Error Discuss

Filed Under: Biology
Exam Prep: Bank Exams

1 3881
Q:

Guess which number should be replaced by the "?" in the given series 0,10,1110,3110,132110,?

Answer

1113122110


In given series 2nd number gives number of  which digits present in the 1st number and so on continues for 3rd ,4th,...


Here 1st no. has only one zero, so  2nd no. is 10 and 2nd no. has one 1 and one 0,so 3rd no. is 1110, so like that 5th no. has one 1,one 3,one 2,two 1's and one 0.So the next no. is 1113122110. 


 

Report Error

View answer Workspace Report Error Discuss

Subject: Math Puzzles Exam Prep: CAT
Job Role: Bank PO

13 3879