© 2014 Firstsoft Technologies (P) Limited. login
Hi 'Guest'
Home SiteMap Contact Us Disclaimer
enggedu

C and C++ Interview Questions

Ex 7:

#include"stdio.h"
void main()
{
   
    #ifdef __stdio_h
         prinrf("defined");
    #else
         printf("not defined");
    #endif
 
}

What will be output if you compile and execute the above code?

(a)defined
(b)not defined
(c)Run time error
(d)Compiler error

Ans: (b)

Ex - 8:
#include"stdio.h"
void main()
{
    const int a=1;
  
    #if 5+~5+1
         printf("%d",a+1);
    #elif 7
        printf("%d",a+2);
    #else
         printf("%d",a+3);
    #endif

   }

What will be output if you compile and execute the above code?

(a)2
(b)3
(c)4
(d)Compiler error

Ans: (b)

Ex - 9:  
#define conio.h
#include "stdio.h"
#define max 0\5
void main()
{
   
    #ifndef __conio_h
    #define conio.h
    printf("%s",__TIME__);
    #else
    #undef __conio_h
    printf("%s",__DATE__);
    #endif
}

What will be output if you compile and execute the above code?

(a)Output will be date of compilation
(b)Output will be time of compilation
(c)Output will be both time of compilation and date of compilation
(d)Compiler error

Ans: (b)


1 >> 2 >> 3 >> 4 >> 5
SLogix Student Projects
bottom