Menu

[solved] – Question 9199

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?

Win7 64
Dev C++

#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=4;a>0;a–) {
printf(“Please enter a number 1 – 255: “);
scanf(“%d”,&count);
if(isdigit(count)) {
if(count<=0)
a=2;
else if(count>0 && count<256)
a=0;
else
return 1;
}
else
return 1;
}
while(count>=loopCounter) {
printf(“%dn”,count);
count–;
}
getch();
return EXIT_SUCCESS;
}

Expert Answer


OR


Leave a Reply

Your email address will not be published. Required fields are marked *