Practice Question and Answer

  • Show AnswerHide Answer
  • Workspace

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 do the functions atoi(), itoa() and gcvt () do? Show how would you use them in a program. 1710 0

  • Show AnswerHide Answer
  • Workspace

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 0

  • Show AnswerHide Answer
  • Workspace

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()? 926 0

  • Show AnswerHide Answer
  • Workspace

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()? 997 0

  • Show AnswerHide Answer
  • Workspace

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 0

  • Show AnswerHide Answer
  • Workspace

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.

Q: What is NTFS? 1673 0

  • Show AnswerHide Answer
  • Workspace

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.

      Report Error

    Please Enter Message
    Error Reported Successfully

      Report Error

    Please Enter Message
    Error Reported Successfully

      Report Error

    Please Enter Message
    Error Reported Successfully

      Report Error

    Please Enter Message
    Error Reported Successfully

      Report Error

    Please Enter Message
    Error Reported Successfully

      Report Error

    Please Enter Message
    Error Reported Successfully

      Report Error

    Please Enter Message
    Error Reported Successfully

      Report Error

    Please Enter Message
    Error Reported Successfully