3
Q:

What will be output of following program?


#include <stdio.h>
int main()

{
   void (*p)();
   int (*q)();
   int (*r)();
   p = clrscr;
   q = getch;
   r = puts;
  (*p)();
  (*r)("www.sawaal.com");
  (*q)();
  return 0;
}

A) NULL B) www.sawaal.com
C) Compilation error D) None of above

Answer:   B) www.sawaal.com



Explanation:

p is pointer to function whose parameter is void and return type is also void. r and q is pointer to function whose parameter is void and return type is int . So they can hold the address of such function.

Subject: Programming
Q:

How would you find the length of each string in the following Program?

main()

{

    char *str[] = { "Frogs", "Do", "Not" , "Die" , "They" , "Croak!"};

    printf ("%d%d", sizeof (str), sizeof (str[0]));

}

Answer

main()


{


   char *str[] = { "Frogs", "Do", "Not", "Die." , "They", "Croak!" };


   int i;


         for ( i = 0;i<=5;i++)


         printf ("\n%s%d", str[i], strlen( str[i]));


}

Report Error

View answer Workspace Report Error Discuss

Subject: Programming

1 1863
Q:

What would be the output of the following program?

main()

{

     char ch ='A';

      printf ("%d%d", sizeof (ch), sizeof ('A'));

}

Answer

1   2

Report Error

View answer Workspace Report Error Discuss

Subject: Programming

0 2384
Q:

What would be the output of the following program, if the array beigns at address 65486?

main()

{

    int arr[] = {12,14,15,23,45};

    printf ("%u %u", arr, &arr);

}

Answer

65486  65486

Report Error

View answer Workspace Report Error Discuss

Subject: Programming

0 1891
Q:

What would be the output of the following program?

main()

{

    char a[] = "Visual C++";

    char *b = "Visual C++";

    printf ("\n%d %d", sizeof (a), sizeof (b));

    printf ("\n%d %d", sizeof (*a), sizeof (*b));

Answer

11  2


 1   1

Report Error

View answer Workspace Report Error Discuss

Subject: Programming

1 1863
Q:

How would you obtain segment and offset addresses from a far address of a memory location?

Answer

#include "dos.h"


main()


{


    Char far *scr = ( char far *) 0xB8000000;


    Char *seg, *off;


    Seg = (char *) FP_SEG ( scr );


    Off = ( char *) FP_OFF ( scr );


}


 

Report Error

View answer Workspace Report Error Discuss

Subject: Programming

0 2147
Q:

How would you eliminate the warning generated on complaining the following program?

main()

{

  char far *scr;

  scr = 0xB8000000;

  *scr = 'A';

}

Answer

Use the typecast scr = (char far *) 0xB8000000;

Report Error

View answer Workspace Report Error Discuss

Subject: Programming

0 1722
Q:

Would the following program compile?

main()

{

    int a = 10, *j;

    void *k;

    J = k = &a;

    J++;

    k++;

   printf ("\n%u %u", j, k);

}

Answer

An error would be reported in the statement k++ since arithmetic on void pointers is not permitted unless the void pointer is appropriately typecasted.

Report Error

View answer Workspace Report Error Discuss

Subject: Programming

0 2411
Q:

What would be the output of the following program assuming that the array beigns at location 1002?

main()

{

   int a[3][4] = {

                            1 , 2 , 3 , 4

                            5,  6 , 7, 8

                            9, 10 , 11, 12

                       };

    Printf ("\n%u %u %u", a[0] + 1, *( a[0] + 1), *( *(a + 0) + 1) );

}

Answer

1004  2  2

Report Error

View answer Workspace Report Error Discuss

Subject: Programming

1 1961