TECHNOLOGIES
FORUMS
JOBS
BOOKS
EVENTS
INTERVIEWS
Live
MORE
LEARN
Training
CAREER
MEMBERS
VIDEOS
NEWS
BLOGS
Sign Up
Login
No unread comment.
View All Comments
No unread message.
View All Messages
No unread notification.
View All Notifications
Answers
Post
An Article
A Blog
A News
A Video
An EBook
An Interview Question
Ask Question
Forums
Monthly Leaders
Forum guidelines
Aditya Singh
NA
1
1.1k
Is this write code to chck prime num?if wrong plz tell m bst
Dec 16 2014 2:51 PM
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace PrimeNumber
{
class Math
{
static void Main(string[] args)
{
Console.WriteLine("Enter a Number : ");
try
{
int num = int.Parse(Console.ReadLine());
if (num == 2 || num == 3 || num == 5 || num == 7)
{
Console.WriteLine("Entered number is Prime number");
}
else if (num % 2 != 0 && num % 3 != 0 && num % 5 != 0 && num % 7 != 0)
{
Console.WriteLine("Entered number is prime number");
}
else
{
Console.WriteLine("Entered number is not prime");
}
}
catch(Exception ee)
{
Console.WriteLine("Exception Raised Please Enter the valid number",ee);
}
Console.ReadLine();
}
}
}
Reply
Answers (
1
)
interop word insert page break
raw Socket in C#