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
What are structure types in C?
how should functions be apportioned among source files?
How can a process change an environment variable in its caller?
how do you programme Carrier Sense Multiple Access
Explain what is the difference between functions getch() and getche()?
What is the code in while loop that returns the output of given code?
What is ## preprocessor operator in c?
There seem to be a few missing operators ..
Is c procedural or functional?
Why header file is used in c?
What is break in c?
What is the difference between local variable and global variable in c?
What is wrong in this statement? scanf(ā%dā,whatnumber);
What is spaghetti programming?
What are pointers? Why are they used?