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 is the size of enum in bytes?

591


What are the types of data types and explain?

673


What is a pointer value and address in c?

636


What are the similarities between c and c++?

601


Write a program to print fibonacci series without using recursion?

611






What are valid signatures for the Main function?

702


Write a c program to build a heap method using Pointer to function and pointer to structure ?

4179


Implement bit Array in C.

678


What are the two types of functions in c?

567


Is it valid to address one element beyond the end of an array?

675


Why is it important to memset a variable, immediately after allocating memory to it ?

1556


int main() { Int n=20,i; For(i=0;i<=n;i--) { Printf(“-“); Return 0;

1128


How do I copy files?

623


Explain what is wrong in this statement?

635


Write a progarm to find the length of string using switch case?

1612