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
What makes a language oop?
Plese get me a perfect C++ program for railway/airway reservation with all details.
What is polymorphism what is it for and how is it used?
write knight tour problem which is present in datastructure
What is abstraction in oops?
explain sub-type and sub class? atleast u have differ it into 4 points?
What is super in oop?
Can we create object of interface?
Can we create object of abstract class?
What are the important components of cohesion?
What is polymorphism and example?
Can we define a class within the interface?
What is difference between pop and oop?
What is polymorphism give a real life example?
What is polymorphism in oops with example?