1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.

Please answer this

Discussion in 'Meet and Greet' started by Fazil RF, Jan 7, 2013.

  1. Fazil RF

    Fazil RF New Member

    Joined:
    Jan 7, 2013
    Messages:
    11
    Likes Received:
    0
    Trophy Points:
    0
    Occupation:
    Student
    Location:
    Erode,Tamil nadu
    main()
    {
    if(1)
    printf("hello");
    else
    printf("world");
    }

    In this C prog, How do print "hello world" by only changing the IF condition
     
  2. NewsBot

    NewsBot New Member

    Joined:
    Dec 2, 2008
    Messages:
    1,267
    Likes Received:
    1
    Trophy Points:
    0
    This would print Hello World.
    Code:
    main()
    {
    if(1)
    printf("hello");
    else;
    printf("world");
    }
    
     
  3. Fazil RF

    Fazil RF New Member

    Joined:
    Jan 7, 2013
    Messages:
    11
    Likes Received:
    0
    Trophy Points:
    0
    Occupation:
    Student
    Location:
    Erode,Tamil nadu
    Thanks:)
    but as i told yesterday,we can change IF condn only:)

    Reply me sir:)
     
  4. NewsBot

    NewsBot New Member

    Joined:
    Dec 2, 2008
    Messages:
    1,267
    Likes Received:
    1
    Trophy Points:
    0
    Code:
    main()
    {
    if(printf("hello") && false)
    printf("hello");
    else;
    printf("world");
    }
     
  5. Fazil RF

    Fazil RF New Member

    Joined:
    Jan 7, 2013
    Messages:
    11
    Likes Received:
    0
    Trophy Points:
    0
    Occupation:
    Student
    Location:
    Erode,Tamil nadu
    ok..Thnks:)
    i'll try it., Thank u so much
     
  6. Fazil RF

    Fazil RF New Member

    Joined:
    Jan 7, 2013
    Messages:
    11
    Likes Received:
    0
    Trophy Points:
    0
    Occupation:
    Student
    Location:
    Erode,Tamil nadu
    Sir,
    what is meant by "false",what actually happened on the following line

    if(printf("hello") && false)

    Reply me:)
     
  7. NewsBot

    NewsBot New Member

    Joined:
    Dec 2, 2008
    Messages:
    1,267
    Likes Received:
    1
    Trophy Points:
    0
    It prints hello and printf returns the number of characters printed which would be 5.

    5 and false would be false as condition and so else would be executed.
     
  8. Fazil RF

    Fazil RF New Member

    Joined:
    Jan 7, 2013
    Messages:
    11
    Likes Received:
    0
    Trophy Points:
    0
    Occupation:
    Student
    Location:
    Erode,Tamil nadu
    Sir,
    it shows error as UNDEFINED LABEL

    Reply soon:)
     
  9. NewsBot

    NewsBot New Member

    Joined:
    Dec 2, 2008
    Messages:
    1,267
    Likes Received:
    1
    Trophy Points:
    0
    You should be able to fix compilation errors because we are not using includes and things like those.
     

Share This Page