2
Q:

What would be the output of the following program ?

main()

{

     const int x = 5; 

      int *ptrx;

      ptrx = &x;

      *ptr = 10;

       printf ("%d", x);

}

A) 5 B) 10
C) Error D) Garbage value

Answer:   B) 10



Explanation:
Subject: Programming
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
Q:

Indicate what would the SWAP macro be expanded to on preprocessing. Would the code compile?

#define SWAP (a, b, c ) (c t; t = a, a = b, b = t; )

main()

{

    int x = 10, y = 20;

    SWAP (x, y, int );

    printf ( " %d%d ", x, y);

}

Answer

( int t ; t = a, a = b, b = t ;);


This code won't compile since declaration of t cannot occur within parentheses.


 

Report Error

View answer Workspace Report Error Discuss

Subject: Programming

0 2816