So i am just starting to learn c programming and i decided to practice by making my program speak to the end-user by asking questions and reacting to them
I first applied if-else statement for the program to react on the age of the person. then, when i get to the whats your favorite color part with the switch statements it would just close upon pressing any button.
My code:
#include <stdio.h>
#include <conio.h>
#include <dos.h>
#include <ctype.h>
main()
{
char name[25], c;
int a;
clrscr();
printf("Hello, whats your name? \n");
scanf("%s",name);
printf("nice to meet you %s!!!\n");
printf("Whats your age?");
scanf("%d",&a");
{
if((a <= 21) && (a >= 0))
printf("Young!\n");
else if((a <= 100) && (a >= 22))
printf("old!\n");
else
printf("that's not an age!\n");
}
printf("whats your favorite color? \n"); //this is where the program stops//
scanf("%c",&c);
switch(tolower(c)){
case 'r':printf("Fiery!");break;
case 'o':printf("oranggerrr!!");break;
.
. //basically applied the whole rainbow and put some reactions//
.
getch();
return 0;
}