Practice Assignment

(numdigits.c)

Information

  1. Write a program that prints out the number of digits in an integer. Here are a few sample runs:
    Enter an integer (1 to 2,147,483,647 without commas): 1776
    The number of digits in 1776 is 4.
    
    Enter an integer (1 to 2,147,483,647 without commas): 8
    The number of digits in 8 is 1.
    
    Enter an integer (1 to 2,147,483,647 without commas): 1357902468                  
    The number of digits in 1357902468 is 10.
    
    The numbers in RED are typed by the user.

    The name of the file should be numdigits.c and the command to compile it will look like this:

    gcc -Werror -Wall -Wextra -ansi -pedantic numdigits.c -o numdigits
    
    output-numdigits.txt This output was generated by running the program 9 times, using each of these numbers:
    1
    42
    555
    1729
    65535
    142857
    8675309
    63288349
    999999937
    2147483647
    

Notes

For students that want to practice their C-fu