In this tutorial learn how you can write a c program to count the number of digits in a number.
We are using the while loop and if statement for this tutorial.
C programming is a powerful general-purpose programming language. It can be used to develop software like operating systems, databases, compilers, etc.
Here is the code to count the number of digits in a number in C programming.
#include <stdio.h> //WAP to count the number of digits in a number. int main() { int num, counter = 0; printf("Enter any numbr of your choices:"); scanf("%d", &num); while (num != 0) { num = num / 10; counter++; } printf("The number of digits are %d.", counter); return 0; }
This is how you can count the number of digits in a number in c programming. Comment below if you like our tutorial.