I attempted to submit this to the C category and the website is broken and I could not submit it in 4 different browsers so I had to submit this under C++. This is a C question. Issue with isdigit. Supposed to look at the first digit and return 0 if non digit entered. It always returns a 0 no matter what. I have attempted changing count to a float. Why isn't this working?
#include <conio.h> #include <iostream> #include <ctype.h> using namespace std; & int main(int argc, char *argv[]) { int loopCounter=0,count=0,a; for(a=2;a>0;a--) { printf("Please enter a number 1 - 255: "); if (scanf("%d*c",&count)) { & if(count<=0) { & printf("%d is not a number between 1 - 255. ",count); & a=2; & } & else if(count>=256) a=2; & else a=0; & } else { & printf("A valid number was not entered.& The program will now close."); & count=-1; & a=0; } } while(count>=loopCounter) { printf("%d\n",count); count--; } getch(); return EXIT_SUCCESS; }
Numbers and figures are an essential part of our world, necessary for almost everything we do every day. As important…
APPROVED BY CLIENTS
"assignmentexpert.com" is professional group of people in Math subjects! They did assignments in very high level of mathematical modelling in the best quality. Thanks a lot
Comments
Leave a comment