Computer Science, asked by katengemonika, 8 months ago

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 Anonymous
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