Answered step by step
Verified Expert Solution
Question
1 Approved Answer
C++ language Write a program in C++ named Digitsininteger.cpp that uses a function countDigits() to count the number of digits in an integer input by
C++ language Write a program in C++ named Digitsininteger.cpp that uses a function countDigits() to count the number of digits in an integer input by the user and return the value of the number of to the calling function. - Write the code for function countDigits() and the main() function with any important header files to include and any namespace specifications. - You do NOT have to essentially write a program that uses a class for this problem but writing a program that uses a function as specified is important, else no points would be admissible even if your code achieves the final results without a function. - It is possible that the user could enter a value with a decimal point. The program should display an error message and ask the user again for a valid number until the user enters a valid integer value. - The user could also enter a negative integer number, which would be treated as a valid input. If it is an integer, your function countDigits( ) must return the number of digits in the negative integer value entered by the user. For example, if the user entered 135782, function countDigits( ) must return 6 (the number of digits in 135782), if the user entered 74, function countDigits() must return 2 (the number of digits in 74 ), if the user entered 0 , function countDigits() must return 0 (the number of digits in 0 ), and so on. - Demonstrate the use of function countDigits() by calling it from main(). - Ask the user if the user wants to perform the counting of the number of digits again and call the function again. Keep asking the user to provide the integer value and keep calling the function until the user wants to exit your program
C++ language
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started