This preview has intentionally blurred sections. Sign up to view the full version.
View Full Document
Unformatted text preview: scanf("%d", &input); if(!IsValid(input))/*Will prompt error message if value isnt in domain*/ { input=GetInput(); } return(input); } int IsValid(int x) { if(x<=9 && x>=1 && x%2!=0)/*if is less than equal to 9, and greater than equal to 1 and not even then it will return*/ {//is it ok return 1; } else /*3 main error messages*/ { if(x%2==0)/*If x is even*/ { printf("You have entered an even number. Please try again.\n"); } if(x>9)/*If x is greater than 9*/ { printf("You have entered a number greater than 9. Please try again.\n"); } if(x<1)/*If x is less than 1*/ { printf("You have entered a number less than 1. Please try again.\n"); } printf("\n"); return 0; } }...
View
Full Document
 Spring '14
 Rafal A. Angryk
 #, Elementary arithmetic, #include, scanf, printf

Click to edit the document details