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

Which interrupts is not level-sensitive in 8085?

Answer

TST 7.5 is a raising edge-triggering interrupt.

Report Error

View answer Workspace Report Error Discuss

Subject: Hardware

2 4092
Q:

'Pencillin' which is used as an antibiotic is obtained from 

A) Bacteria B) Fungi
C) Algae D) Lichens
 
Answer & Explanation Answer: B) Fungi

Explanation:
Report Error

View Answer Report Error Discuss

Filed Under: General Science

16 4092
Q:

What is at the end of a rainbow?

Answer

The logical answer for a puzzle is that the letter 'W'.


 


A rainbow is a spectrum of light that appears in the sky when sunlight is refracted through raindrops or other drops of moisture in the Earth's atmosphere. They have inspired much popular folklore, including the belief that a leprechaun can be found with a pot of gold at the end of a rainbow.

Report Error

View answer Workspace Report Error Discuss

3 4091
Q:

Math Logic Challenge

18582095_1309614185812349_1823149961450714717_n1499156071.jpg image

A) 23 B) 26
C) 13 D) 29
 
Answer & Explanation Answer: B) 26

Explanation:

Let the integer be x. Then,

 x2-20x = 156

 

(x + 6)(x - 26) = 0

 

x = 26

 

The integer is 26.

Report Error

View Answer Report Error Discuss

Filed Under: Math Puzzles
Exam Prep: GATE , CAT , Bank Exams , AIEEE
Job Role: Bank PO , Bank Clerk

12 4090
Q:

Number of moles of CO2 present in 24 grams of carbon is

A) 0.5 B) 1
C) 2 D) 0.25
 
Answer & Explanation Answer: C) 2

Explanation:

1 mole of CO2 contain 12gms of carbon and 44 gms of CO2

therefore  24 gms of carbon is present in 88 gms of CO2 or 2 moles of CO2

Report Error

View Answer Report Error Discuss

Filed Under: Chemistry

7 4090
Q:

If there are 17 randomly placed dots on a circle,how many lines can you form using any 2 dots?

A) 126 B) 130
C) 136 D) 120
 
Answer & Explanation Answer: C) 136

Explanation:

17C2 = 136 (combination)

Report Error

View Answer Report Error Discuss

0 4089
Q:

DTS supports which of the following choices?

A) Generation of Travel authorizations B) Route travel requests for approval
C) Trip reservations D) All of the above
 
Answer & Explanation Answer: D) All of the above

Explanation:
Report Error

View Answer Report Error Discuss

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

3 4089