Answer to Question #180100 in C++ for saif islam

Question #180100

Smith is a course instructor of cpp programming and currently he is teaching conversions to his students. He started with the basic programs and now he want to introduce some complex problems. Before starting the complex problems, he wants to start with high difficulty level problem, such as: counting the digits of a number. Help Mr. Smith to write a program which will accept one integer argument and returns count of digits of that argument using class to class conversion. 


1
Expert's answer
2021-04-11T18:39:45-0400
#include <iostream>
#include <string>
int main(){
    int x;
    std::cout<<"Enter the number(integer): ";
    std::cin>>x;
    std::cout<<"The count of digits in "<<x<<" is ";
    std::cout<<std::to_string(abs(x)).length();
    return 0;
}

Need a fast expert's response?

Submit order

and get a quick answer at the best price

for any assignment or question with DETAILED EXPLANATIONS!

Comments

No comments. Be the first!

Leave a comment

LATEST TUTORIALS
New on Blog
APPROVED BY CLIENTS