C/C++ Digit Cheaking System
This code can cheak how much digit number you have typed if your number is 3 digit than this code will reply Yes else this code will tell How Many digit Number you have typed.
code:
#include <stdio.h>
int main() {
printf("Type Here to Enter Something... :");
int num;
int count = 0;
scanf("%d",&num);
printf("\n");
if(num > 99 && num < 1000){
printf("Yes it is 3 digit number \3 \4 \2 \1 \5 ");
}
if(num < 99 || num > 999){
printf("\nNo it's not a 3 digit Number\n");
}
if(num > 1){
printf("\n");
}
else{
printf("\nError You Have Entered Wrong Input!\n");
}
if (num < 0) {
num = -num;
}
if (num == 0) {
count = 1;
} else {
while (num != 0) {
num /= 10;
count++;
}
}
printf("Number of digits: %d\n", count);
printf("\n");
return 0;
}
No comments:
Post a Comment