How can i write a code in c# to take a number from the user
and then find all the prime numbers till the number entered
by the user.
Answer Posted / shuklaamit565
using System;
class Test2
{
public static void Main()
{
int prime,num=100;
for(int i = 3; i <num; i++)
{
prime = 1;
for(int n = 2; n <= i - 1;
n++)
{
if(i % n == 0)
{
prime = 2;
}
}
if(prime==1)
{
Console.WriteLine( "
is prime :"+i);
}
}
}
}
Is This Answer Correct ? | 0 Yes | 0 No |
Post New Answer View All Answers
Get me an image implementation program.
class type to basic type conversion
What is a function in oop?
What is methods in oop?
What does and I oop mean in text?
What does it mean when someone says I oop?
What is the main feature of oop?
What is the diamond problem in inheritance?
Can an interface inherit a class?
What is the difference between a constructor and a destructor?
What does and I oop mean?
What is static modifier?
What is encapsulation example?
Describe these concepts: Polymorphism, Inheritance and Abstraction.
what type of question are asked in thoughtworks pair programming round ?