Practice Question and Answer
8Q: If I use the following printf() to print a long int why I am not warned about the type mismatch? printf ("%d",num ); 837 05b5cc7dce4d2b419777515b8
5b5cc7dce4d2b419777515b8- Show AnswerHide Answer
- Workspace
- SingleChoice
Answer :
Explanation :
When a function accepts a variable number of arguments , its prototype cannot provide any information about the number of arguments and type of those variable arguments. Hence the compiler cannot warn about the mismatches. The programmer must make sure that arguments match or must manually insert explicit typecast.
Q: What would be the output of the following program? main() { char huge * near * far *ptr1; char near * far * huge *ptr2; char far * huge * near *ptr3; printf ("%d%d%d", sizeof (ptr1), sizeof (ptr2), sizeof (ptr3)); } 924 05b5cc7dce4d2b419777515b7
5b5cc7dce4d2b419777515b7- Show AnswerHide Answer
- Workspace
- SingleChoice
Answer :
Explanation :
4 4 2
Q: What do the functions atoi(), itoa() and gcvt () do? Show how would you use them in a program. 1710 05b5cc7dce4d2b419777515b6
5b5cc7dce4d2b419777515b6- Show AnswerHide Answer
- Workspace
- SingleChoice
Answer :
Explanation :
atoi() Converts a string to an integer. itoa() Convert an integer to a string gcvt() Converts a floating-point number to a string #include "stdlib.h" main() { char s[] = "12345"; char buffer [15], string[20]; int i; i = atoi (s); printf("\n%d",i); gcvt (20.141672, 4, buffer); printf ("\n%s", buffer); itoa(15, string,2); printf ("\n%s", string); }
Q: How would you use qsort() function to sort an array of structures? 1663 05b5cc7dce4d2b419777515b5
5b5cc7dce4d2b419777515b5- Show AnswerHide Answer
- Workspace
- SingleChoice
Answer :
Explanation :
#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); }
Q: How would you use the function memmove()? 927 05b5cc7dce4d2b419777515b4
5b5cc7dce4d2b419777515b4- Show AnswerHide Answer
- Workspace
- SingleChoice
Answer :
Explanation :
#include "mem.h" #include "alloc.h" main() { int area; char *dest; char src[] = "Life is the camera and you are the target" "so keep smiling always"; area = sizeof (src); dest = malloc (area); memmove (dest, src, area); printf("\n%s", dest); printf("\n%s",src); }
Q: What's the difference between the functions rand(), random(), srand() and randomize()? 998 05b5cc7dce4d2b419777515b3
5b5cc7dce4d2b419777515b3- Show AnswerHide Answer
- Workspace
- SingleChoice
Answer :
Explanation :
rand() returns a random number random() returns a random number in a specified range srand() initialise a random number generator with a given seed value randomize() initializes a random number generator with a random value based o time.
Q: In Windows XP , what does the letter XP stands for? 2146 05b5cc7dce4d2b419777515b2
5b5cc7dce4d2b419777515b2- Show AnswerHide Answer
- Workspace
- SingleChoice
Answer :
Explanation :
The letters XP actually stands for eXPerience. It was designed as an enhancement of Windows 2000, with a totally different and more attractive user interface/console.
- Show AnswerHide Answer
- Workspace
- SingleChoice
Answer :
Explanation :
NTFS is short for New Technology File System. It is the standard file system that is being used by operating systems starting from Windows NT, Windows 2000, Windows XP, and even the newer versions like Vista and 7. It was originally designed to have a better performance on file storage and retrieval under the Windows NT family.

