Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- using System.Collections.Generic;
- using System.Linq;
- using System.Text;
- using System.Threading.Tasks;
- namespace DigitCounter
- {
- class Program
- {
- static void Main(string[] args)
- {
- Console.WriteLine("Count Number of Digits of a Given Number");
- int n = Convert.ToInt32(Console.ReadLine());
- int remainder = 0, count = 0; string sum = string.Empty;
- string N = string.Empty;string f=string.Empty;
- N = n.ToString();
- while (n != 0)
- {
- remainder = n % 10;
- sum = sum + remainder;
- n = n / 10;
- count++;
- }
- for (int i = sum.Length-1; i >= 0; i--)
- {
- f = f + sum[i];
- }
- if (f== N)
- {
- Console.WriteLine("The number of digits in the number is={0}", count);
- }
- Console.ReadLine();
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement