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

I came across some code that puts a (void) cast before each call to printf. Why?

675


How are pointers declared in c?

592


What is optimization in c?

562


what is recursion in C

607


What are the primitive data types in c?

570






What is the behavioral difference when include header file in double quotes (“”) and angular braces (<>)?

809


What is a far pointer in c?

592


What is a list in c?

616


#include show(int t,va_list ptr1) { int a,x,i; a=va_arg(ptr1,int) printf(" %d",a) } display(char) { int x; listptr; va_star(otr,s); n=va_arg(ptr,int); show(x,ptr); } main() { display("hello",4,12,13,14,44); }

764


"C" language developed by "Dennis Ritchie" at AT & T. his remarks are a) too general, too abstract b) could deal with only specific problems c) lost generality of BCPL and B restored d) no remarks

652


Is it fine to write void main () or main () in c?

543


What is the purpose of macro in C language?

659


What are the ways to a null pointer can use in c programming language?

588


A collection of data with a given structure for excepting storing and providing on demand data for multiple users a) linked list b) datastructer c) database d) preprocessor

620


program to find out date after adding 31 days to a date in the month of febraury also consider the leap year

2575