Find the output for the following code (4)

rengaraj

rengaraj

@rengaraj-89Rrct Oct 21, 2024
Sir / Madam,
My question is

Find the output for the following code

#define one 0
#ifdef one 
printf("one is defined ");
#ifndef one
printf("one is not defined ");

Advance Thanks,
R.Rengaraj
{Java Certification Quiz}
{On this forum my 21st Question.}

Replies

Welcome, guest

Join CrazyEngineers to reply, ask questions, and participate in conversations.

CrazyEngineers powered by Jatra Community Platform

  • sarveshgupta

    sarveshgupta

    @sarveshgupta-txtmu5 Dec 12, 2009

    Is the answer

    one is defined
  • rengaraj

    rengaraj

    @rengaraj-89Rrct Dec 12, 2009

    Hi,
    Yes, you are right but 0 denotes false in C.
    If value of one , 0 is applied. Then the next printf will not be executed.
    But we get "one is defined" how ?
    R.Rengaraj
  • gaurav.bhorkar

    gaurav.bhorkar

    @gauravbhorkar-Pf9kZD Dec 12, 2009

    rengaraj
    Hi,
    Yes, you are right but 0 denotes false in C.
    If value of one , 0 is applied. Then the next printf will not be executed.
    But we get "one is defined" how ?
    R.Rengaraj
    #define one 0
    This directive defines "one".

    #ifdef one 
    printf("one is defined ");
    #ifndef one
    printf("one is not defined ");
    These directives check whether "one" is defined or not, irrespective of the value "one" takes.
  • Sahithi Pallavi

    Sahithi Pallavi

    @sahithi-oJZaYj Dec 12, 2009

    Good answer Gaurav..!
  • gaurav.bhorkar

    gaurav.bhorkar

    @gauravbhorkar-Pf9kZD Dec 12, 2009

    sahithi pallavi
    Good answer Gaurav..!
    Thank You!
  • sarveshgupta

    sarveshgupta

    @sarveshgupta-txtmu5 Dec 12, 2009

    Good answer Gaurav
  • rengaraj

    rengaraj

    @rengaraj-89Rrct Dec 15, 2009

    Thanks...
    R.Rengaraj