Write an algorithm, draw flowchart and write program in C# Console Application to
Check whether the given number is prime or not
aim, algorithm and flowchart
Answers
Answered by
0
Answer:
using System;
public class funcexer9
{
public static bool chkprime(int num)
{
for (int i=2; i < num; i++)
if (num %i == 0)
return false;
return true;
}
public static void Main()
{
Console.Write("\n\nFunction : To check a number is prime or not :\n");
Console.Write("--------------------------------------------------\n");
Console.Write("Input a number : ");
int n= Convert.ToInt32(Console.ReadLine());
if (chkprime(n))
Console.WriteLine(n+" is a prime number");
else
Console.WriteLine(n+" is not a prime number");
}
}
Similar questions
Math,
4 months ago
Political Science,
4 months ago
Biology,
4 months ago
Accountancy,
8 months ago
Biology,
8 months ago
English,
1 year ago