Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- using System.Collections.Generic;
- using System.Text;
- namespace primeorcomposite
- {
- class prime_or_Composite
- {
- static void Main()
- {
- int a,cont=1;
- bool flag=true;
- get_input:
- flag = true;
- Console.Write("\n\nEnter any number: ");
- a = int.Parse(Console.ReadLine());
- for (int i = 2; i < a; i++)
- {
- if (a % i == 0)
- {
- flag = false;
- break;
- }
- }
- if (!flag)
- {
- Console.ForegroundColor = ConsoleColor.Red;
- Console.Beep(500, 500);
- Console.WriteLine("\n{0} is not a Prime Number!", a);
- }
- else
- {
- Console.ForegroundColor = ConsoleColor.Green;
- Console.Beep(1000, 500);
- Console.WriteLine("\n{0} is a Prime Number!", a);
- }
- Console.ForegroundColor = ConsoleColor.Gray;
- Console.WriteLine("\nContinue? < 1 or 0 >");
- cont = int.Parse(Console.ReadLine());
- if (cont == 1)
- goto get_input;
- else
- {
- Console.WriteLine("Thank You!\nExiting.......");
- Console.Beep(750, 300) ;
- Console.Beep(750, 300);
- Console.Beep(750, 300);
- }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement