0

Hello Everyone,
My name is olams and i am new to this website and C++ in general. I am having real difficulty in this class.
Can someone please tell me how to find the number of digits in number using Visual C++. Net or C++.
I really need help. Any assistance is greatly appreciated.
Thanks

2
Contributors
2
Replies
9
Views
10 Years
Discussion Span
Last Post by olams
0

Assuming the given number is an integer, try dividing it by 10...

int num_digits;
if (myNumber < 0)
    myNumber = -myNumber;

while(myNumber > 0) {
    num_digits++;
    myNumber/=10;
}
0

Thanks Joe Programmer. I actually already figured it out. Thank you for yur time. I do really appreciate it
]

Assuming the given number is an integer, try dividing it by 10...

int num_digits;
if (myNumber < 0)
    myNumber = -myNumber;
 
while(myNumber > 0) {
    num_digits++;
    myNumber/=10;
}
This question has already been answered. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.