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

What are shell structures used for?

600


difference between object file and executable file

6095


What is the use of getchar functions?

674


How can a process change an environment variable in its caller?

656


Explain the advantages of using macro in c language?

582






Differentiate between new and malloc(), delete and free() ?

675


Why isnt any of this standardized in c?

633


Differentiate call by value and call by reference?

569


Explain what is the difference between #include and #include 'file' ?

585


What are the string functions? List some string functions available in c.

605


Are pointers integers in c?

611


.find the output of the following program? char*myfunc(char*ptr) { ptr +=3; return (ptr); } int main() { char*x,*y; x="HELLO"; y=myfunc(x); printf("y = %s ",y); return 0; }

1996


Explain continue keyword in c

586


What functions are in conio h?

658


Why do we need a structure?

587