Use of if else (heaven/hell)

 #include<stdio.h>

#include<conio.h>

void main( )

{

          int i ;


printf ( "Enter either 1 or 2 :" ) ;

scanf ( "%d", &i ) ;


if ( i == 1 )

printf ( "You would go to heaven !\n" ) ;


else

{

if ( i ==2 )

printf ( "Hell was created with you in mind\n" ) ;


else

printf ( "How about mother earth !\n" ) ;

}


getch() ;


}

Output 1 : 

Enter either 1 or 2 : 1

You would go to heaven !


[Process completed (code 10) - press Enter]


Output 2 :

Enter either 1 or 2 : 2

Hell was created with you in mind


[Process completed (code 10) - press Enter]


Output 3 :

Enter either 1 or 2 : 7

How about mother earth !


[Process completed (code 10) - press Enter]

Comments

Popular Post

Define a class to represent a Bank Account. Include the following members: Data Members: i. Name of the depositor ii. Account number iii. Type of account iv. Balance amount in the account Member Functions: 1. To Input initial values 2. To deposit an amount 3. To withdraw an amount after checking the balance 4. To display name and balance Also write constructor for this class that takes four arguments. It should also handle type of account as savings by default