This C++ program asks the user to input a number, divides the number by 10 repeatedly in a while loop to count the digits, and displays the number of digits in the given number. It uses header files for input/output streams, clears the screen, gets the number from the user, divides and increments a counter in the loop, and outputs the digit count.
This C++ program asks the user to input a number, divides the number by 10 repeatedly in a while loop to count the digits, and displays the number of digits in the given number. It uses header files for input/output streams, clears the screen, gets the number from the user, divides and increments a counter in the loop, and outputs the digit count.
This C++ program asks the user to input a number, divides the number by 10 repeatedly in a while loop to count the digits, and displays the number of digits in the given number. It uses header files for input/output streams, clears the screen, gets the number from the user, divides and increments a counter in the loop, and outputs the digit count.
h> #include<conio.h> void main() { int no,a=0; clrscr(); cout<<"Enter any num : "; cin>>no; while(no>0) { no=no/10; a++; } cout<<"\n no. of digits in given number is: "<<a; getch(); }