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

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;
}

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;
}
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.