write the program for prime numbers?

Answer Posted / vinay tiwari

try this u can find out all prime number between 2 and any
number entered by user .i write code in c# language but
concept remain same in any language.
using System;
using System.Collections.Generic;
using System.Text;

namespace ConsoleApplication23
{
class Program
{
static void Main(string[] args)
{
int i=2, j, rem;
while (i <= 100)
{
for (j = 2; j < i; j++)
{
rem = i % j;
if (rem == 0)
break;
}
if (i == j)
Console.WriteLine(i);
i++;
}
}
}
}

Is This Answer Correct ?    250 Yes 136 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

What does c value mean?

843


What are the general description for loop statement and available loop types in c?

886


the 'sizeof' operator reported a larger size than the calculated size for a structure type. What could be the reason?

736


What is the c value paradox and how is it explained?

771


Under what circumstances does a name clash occur?

912


Is main is user defined function?

831


What are types of functions?

739


Write program to remove duplicate in an array?

779


What is difference between structure and union in c programming?

754


What is the use of structure padding in c?

774


What are different storage class specifiers in c?

836


What is structure padding and packing in c?

789


What functions are in conio h?

867


my project name is adulteration of chille powder.how can i explain it to the hr when he asks me about the project?

1323


What is meant by high-order and low-order bytes?

823