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 ConsoleApplication4
- {
- class Program
- {
- static void Main(string[] args)
- {
- int num, x, y, z = 0;
- Console.WriteLine("Enter a number");
- num = int.Parse(Console.ReadLine());
- Console.WriteLine("Enter a digit");
- x = int.Parse(Console.ReadLine());
- while (x < 0 || x > 9)
- {
- x = int.Parse(Console.ReadLine());
- }
- while (num > 0)
- {
- y = num;
- y = y % 10;
- if (y == x)
- {
- z++;
- }
- num /= 10;
- }
- Console.WriteLine("The digit appears " + z + " in the number");
- Console.ReadKey();
- }
- }
- }
Add Comment
Please, Sign In to add comment