Question:C code to count the total number of digit using for loop 

Answer 
#include<stdio.h>
int main(){
  int num,count=0;

  printf("Enter a number: ");
  scanf("%d",&num);

  for(;num!=0;num=num/10)
      count++;

  printf("Total digits is:  %d",count);

  return 0;
}
Sample output: Enter a number: 456 Total digits is: 3 

+ Report
Total Preview: 500
C code to count the total number of digit using for loop
Copyright © 2025. Powered by Intellect Software Ltd