Home > Article > Backend Development > How to determine how many digits an integer has in C language
Implementation code:
#include <stdio.h> int main() { long long a; int count=0; printf("请输入一个整数:"); scanf("%lld",&a); while(a!=0) { a/=10; count++; } printf("输入的数字是%d位数。",count); }
where long long is a long integer and lld is the input method of this type. In this program, count is a counter that records the bits of the input number. number.
Recommended tutorial: c language tutorial
The above is the detailed content of How to determine how many digits an integer has in C language. For more information, please follow other related articles on the PHP Chinese website!