I wrote this code to see how many digits are in a number. I'm assuming that the user uses a number with no more than four digits. For some reason, the code is skipping the if statement. I've checked other questions related to this, but I don't have the same errors. Can you help me? Here is the code that I wrote:
#include "stdafx.h"
int main()
{
char d1;
char d2;
char d3;
char d4;
printf("Please enter a number with four or less digits:");
scanf("%c%c%c%c", &d1, &d2, &d3, &d4);
printf("%c%c%c%c\n", d1, d2, d3, d4);
int d1v2 = d1;
int d2v2 = d2;
int d3v2 = d3;
int d4v2 = d4;
printf("%c%c%c%c\n", d1v2, d2v2, d3v2, d4v2);
int num = (d1v2 * 1000) + (d2v2 * 100) + (d3v2 * 10) + d4v2;
printf("%d", num);
int numv2 = num;
if (numv2 < 10) {
printf("Your number has 1 digit\n");
}
else if (numv2 >= 10 && numv2 < 100) {
printf("Your number has 2 digits\n");
}
else if (numv2 >= 100 && numv2 < 1000) {
printf("Your number has 3 digits\n");
}
else if (numv2 >= 1000 && numv2 < 10000) {
printf("Your number has 4 digits\n");
}
}