Answer to Question #13354 in Visual Basic for sakura

Question #13354
Create a program that will input a number and will count the number of digits.
Enter a number: 12345
Number of Digits: 5
Try again [y/n]?
1
Expert's answer
2012-08-21T10:23:09-0400
#include<stdio.h>
#include<conio.h>
#include <string>
#include <iostream>
using namespace std;
int main()
{
char ch=' ';
do{
unsigned long int num;
int numberofdigits=0;
printf("Enter a number: ");
scanf("%lu",&num);
while(num!=0)
{
num=num/10;
numberofdigits++;
}
printf("Number of Digits: %d",numberofdigits);
printf("
Try again [y/n]?
");
cin>>ch;
}while(ch!='n');
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
APPROVED BY CLIENTS