Program to count number of digits in C

Source Code

// 21.i. Program to count number of digits
// Arpan Das - CST 2nd Year (VOCLET)

#include <stdio.h>
//#include <conio.h>

int main() {
	int num, digits=0;

	printf("Please enter any number: ");
	scanf("%d", &num);

	while (num != 0) {
		num /= 10;

	printf("\nNumber of digits: %d", digits);



Please enter any number: 1234

Number of digits: 4

Please enter any number: 720

Number of digits: 3

Please enter any number: 9831098310

Number of digits: 10

Leave a Reply

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