Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Write a program to read an integer number and find its number of digits (for exa

ID: 3620426 • Letter: W

Question

Write a program to read an integer number and find its number of digits (for example, 3459 has 4 digits and 125860 has 6 digits).

The program should be designed in a way that the user could test as many numbers as desired without leaving the program. Use only long integer ( int or long int ) data type in this problem; however make sure that the program rejects any input outside the long integer data range(about -2,000,000,000 to +2,000,000,000).

The outputs of the program should be written to an output file having a format exactly like the following table.



VALUE ENTERED NUMBER OF DIGITS
1241 4
19 2
5684900 7
0 1
1267678901 10
-153 3
62000 5




Test the program for at least seven integer values between ± 2,000,000,000 and a number outside the long int data range . Remember to submit a copy of the program file and a copy of the output file.

Explanation / Answer

here is the source. It ran according to expectations. If you have any questions ask; but, i think the program is self explanatory. #include #include using namespace std; int main(void){ fstream output; long int num ; // you cant use small c, as cout is a keyword in c++. char exit = NULL; output.open("output.txt", fstream::out); output
Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote