dimanche 31 mai 2015

Printing an int value obtained from user

The problem is at the "age" part, the compiler does not give me any errors but when i run it it prints a random number for int "age"

    printf("Enter your name:");
    scanf(" %s",&name1);
    int age;
    printf("\n\nHow old are you?");
    scanf(" %d",&age);
    char gender;
    printf("\n\nEnter your gender[Male/Female]:");
    scanf(" %s",&gender);
    char confirmation;
    printf("Confirmation: Your name is %s , you are %d years old , and you are a %s.\n\nAnswer[Y/N]:",&name1,age,&gender);




Aucun commentaire:

Enregistrer un commentaire