write the program for prime numbers?

Answer Posted / mudassir shakil

using System;
class Prime_Checker
{
int i;
int counter=0;
int n;
Console.WriteLine("Enter the number");
n=int.Parse(Console.ReadLine());
for(i=2;i<=n;i++)
{
if(n%i==0)
{
counter=1;
}
if(counter=0)
{
Console.WriteLine("No is prime");
}
else
{
Console.WriteLine("No is not prime");
}
}
}

Is This Answer Correct ?    1 Yes 3 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

With the help of using classes, write a program to add two numbers.

622


Take an MxN matrice from user and then sum upper diagonal in a variable and lower diagonal in a separate variables. Print the result

1473


can we implement multi-threads in c.

672


Write a code to determine the total number of stops an elevator would take to serve N number of people.

735


What is a null string in c?

593






What does the file stdio.h contain?

608


why use "return" statement a) on executing the return statement it immediately transfers the control back to the calling program b) it returns the value present in the parentheses return, to the calling program c) a & b d) none of the above

615


What is the difference between variable declaration and variable definition in c?

566


How can variables be characterized?

1654


Explain what is the benefit of using enum to declare a constant?

594


What is function pointer c?

589


What is the difference between fread buffer() and fwrite buffer()?

676


What is the basic structure of c?

561


What is a stream water?

663


write a program that reads lines(using getline), converts each line to an integer using atoi, and computes the average of all the numbers read. also compute the standard deviation.

1989