ADVERTISEMENT
ADVERTISEMENT

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.

/*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; 
}
    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



Comments and Discussions


ADVERTISEMENT

ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT

Languages: » C » C++ » C++ STL » Java » Data Structure » C#.Net » Android » Kotlin » SQL
Web Technologies: » PHP » Python » JavaScript » CSS » Ajax » Node.js » Web programming/HTML
Solved programs: » C » C++ » DS » Java » C#
Aptitude que. & ans.: » C » C++ » Java » DBMS
Interview que. & ans.: » C » Embedded C » Java » SEO » HR
CS Subjects: » CS Basics » O.S. » Networks » DBMS » Embedded Systems » Cloud Computing
» Machine learning » CS Organizations » Linux » DOS
More: » Articles » Puzzles » News/Updates

© https://www.includehelp.com some rights reserved.