All pastes #1317 Raw Edit

Segosa

public cpp v1 · immutable
#1317 ·published 2004-10-07 16:32 UTC
rendered paste body
// returns true or false depending on whether the ISBN// number passed to the function is valid or not.// // if it is not valid, the variable checksum will be the// correct checkdigit.bool isvalidISBN(char *dig,int *checksum){	remdash(dig); // removes the dashes from an ISBN number	if (!atoi(dig))		return false;	int checkdig = dig[strlen(dig)-1]-'0';	dig[strlen(dig)-1] = '\0';	int i,j = 2,total = 0;	for (i = (int)strlen(dig)-1;i>=0;i--)	{		total += (dig[i] - '0') * j;		j++;	}	int check = 11 - (total % 11);	*checksum = check;	if (checkdig == check)		return true;	else		return false;}