#include<iostream>
using namespace std;
int main()
{
int *number=new int[1000];
int c=0;
int i=0;
cout<<"Enter no sir\n";
cin>>number[i];
while(number[i]>0)
{
number[i]/=10;
c++;
}
cout<<"\n\n"<<"TOTAL NO OF DIGITS = "<<c;
delete[]number;
return 0;
}
champu8
0
Newbie Poster
Recommended Answers
Jump to Postchar ch; cin>>ch; if(ch=='SU') { run this code..etc }
first : char only hold one character
second : '' only work on single character but "" for string(multiple characters)
third : the built in typechar
do not support "=="
Jump to Postint number = 10; size_t accumulate = 0; while(number > 0) { number /= 10; //++accumulate would be a better choice, since it would not produce temporary object for some types //although for primitive type ++c or c++ is trivial, but using prefix ++ is a good …
Jump to PostOn most modern compilers, a long is a 32-bit integer value, the same as an int. If your compiler and/or system support it, I would consider a long long if you want a value that has more than 10 digits. With this type, you would now be limited to 19 …
All 10 Replies
champu8
0
Newbie Poster
CBots
0
Newbie Poster
champu8
0
Newbie Poster
champu8
0
Newbie Poster
stereomatching
17
Posting Whiz in Training
stereomatching
17
Posting Whiz in Training
Fbody
682
Posting Maven
Featured Poster
champu8
0
Newbie Poster
champu8
0
Newbie Poster
champu8
0
Newbie Poster
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.