Program to find the length of a number in c and cplusplus (cpp)

Program to find the length of a number in c and C plus plus (cpp)

Suppose the number is 5698, then we can find the length of this number by logic as;

  1. Divide the number with 10, and the result will be 5698/10 = 570
  2. Divide the 570 with 10, and the result will be 570/10 = 57
  3. Divide the 57 with 10, and the result will be 57/10 = 6
  4. Divide the 6 with 10. and the result will be 6/10 = 0

Congratulations: You successfully find the length of the number. Similarly, you can find the length of any number.

Flowchart to find the length of a number

length of a number in c and cplusplus (cpp)
          Figure: length of a number.

Program to find the length of a number in C++ (CPP)

 

With Comments – Program to find the length of a number in C++ (CPP)

Output:

length of a number in c output
Figure: length of a number.

Program to find the length of a number in C

With Comments – Program to find the length of a number in C++ (CPP)