Wednesday, September 23, 2015

Using if else construct in C - II

#include <stdio.h>
#include <conio.h>

void main ()
{
                clrscr();
                int a;
                printf("FORTUNE TELLER\n");
                printf("please Enter a number between 1 and 5:\t");
                scanf("%d", &a);
                if (a==1)
                {
                                printf("You will have a nice day\n");
                }
                else if (a==2)
                {
                                printf("You will meet some one special today\n");
                }
                else if (a==3)
                {
                                printf("You will win a lottery today\n");
                }
                else if (a==4)
                {
                                printf("You will get a special gift today\n");
                }
                else if (a==5)
                {
                                printf("You will find your true love today today\n");
                }
                else
                {
                                printf("Please enter a number between 1 and 5\n");
                }
                getch();
}
Output:  
FORTUNE TELLER
Enter a number between 1 and 5:   5
You will find true love today.


No comments:

Post a Comment