Commonly Asked Interview Questions

Note :  All the programs are tested under Turbo C/C++ compilers and it is assumed that,
  • Programs run under DOS environment,
  • The underlying machine is an x86 system,
  • Program is compiled using Turbo C/C++ compiler.
  • The program output may depend on the information based on this assumptions (for example sizeof(int) == 2 may be assumed). 
Predict the output or error(s) for the following:


  1. void main()
    {
    int const * p=5;
    printf("%d",++(*p));
    }
    Compiler error: Cannot modify a constant value.

    p is a pointer to a "constant integer". But we tried to change the value of the "constant integer".



  2. void main()
    {
    int const * p=5;
    printf("%d",++(*p));
    }
    Compiler error: Cannot modify a constant value.

    p is a pointer to a "constant integer". But we tried to change the value of the "constant integer".




Comments

Popular posts from this blog

Write a Program to Add two 3x3 Matrix using C

C program for Unit Conversion

Write a Program to Add two 5x5 Matrix using C