C Programming Tutorial – 13 – if :

Code:
—————————

#include <stdio.h>
#include <stdlib.h>

int main()
{

int Yourage;
char gender;
printf(“How old are you?\n”);
scanf(” %d”,&Yourage);
printf(“what is your gender? (m/f)\n”);
scanf(” %c”,&gender);

if(Yourage>=18)
{
if(gender == ‘m’) // compare the char value
{
printf(“welcome dude !\n”);
}

if(gender == ‘f’)
{
printf(“welcome m’lady !\n”);
}

}

if(Yourage <18)
{
printf(“You can not visit this website.\n”);
}

return 0;

}