Monday, June 19, 2017

Print "Hello World" Using if-else Condition.

/* Here "Hello World!" is printed using if-else condition. "Hello" printed in if condition and "World" printed in else condition. */


/* Using C */
#include<stdio.h>

int main(){
    if(printf("Hello ") == 0){
        printf("Hello ");
    }
    else{
        printf("World!");
    }
    return 0;
}



/* Using C++ */
#include<iostream>
using namespace std;

int main(){
    if(cout << "Hello " == 0){
        cout <<"Hello ";
    }
    else{
        cout << "World!";
    }
return 0;
}

No comments:

Post a Comment