i'm new to C programming and I have an assignment coming up which I was struggling to work on. My question is that I want to ask the user to Enter in an International Standard Book Number (ISBN) but IF the number does not satisty 9780306406157 then it is an invalid ISBN number. I tried my code but for some odd reason anytime if the user enters 9780306406157 it gives me an Invalid ISBN number which is wrong... Here is my code,
#include<stdio.h>
int main()
{
int isbn;
printf("Enter 13 digits of ISBN-13: ", isbn);
scanf("%1d", &isbn);
int isbn_13 = 9780306406157;
if (isbn == isbn_13)
{
printf("Valid ISBN number.");
}
else if (isbn != isbn_13)
{
printf("Invalid ISBN number. ");
}
return 0;
}
Aucun commentaire:
Enregistrer un commentaire