Home »
        C solved programs »
        C puzzles Programs
    
    Program to print "Hello C" using if and else statement both
    
    
    
    Well, this is not possible, Compiler either execute if or else statement, but we can make fool to other as We are executing if and else both.
    Source Code
/*Program to print "Hello C" using if and else 
statement both.*/
 
#include <stdio.h>
int main() 
{ 
    if(!printf("Hello ")) 
        ; 
    else
        printf("C\n"); 
    return 0; 
}
Output
HelloC 
    Explanation
    In if(!printf("Hello "))  statement printf will print "Hello " and return 6 (number of printed character), hence condition will be false but to !6 that is 0, then execution will jump to else block.
    
    
  
    Advertisement
    
    
    
  
  
    Advertisement