Hi.
I'm currently working on a programme for college but am stuck on an IF statement!
The code seems correct and the programme works fine untill the IF statement where it appears the IF statement is jumped over and the programme quits.
Code:
#include <stdio.h>
#include <stdlib.h>
int main(void)
{
char surname[30];
char initial[1];
char dob[8];
int choice;
printf("Please enter your surname: ");
scanf("%s", surname);
printf("Please enter your initial: ");
scanf("%s", initial);
printf("Please enter your date of birth in the DD/MM/YYYY format: ");
scanf("%d", dob);
system("cls");
printf("1 - Arithmetic \n");
printf("2 - Conversion \n");
printf("3 - Result \n");
printf("Please choose a number to continue: ");
scanf("%d",&choice);
if(choice==1)
{
printf("You chose 1");
}
else if(choice==2)
{
printf("You chose 2");
}
return(0);
}
That's the code. It works fine until the final printf.
Any ideas?
Cheers.