Golgappa.net | Golgappa.org | BagIndia.net | BodyIndia.Com | CabIndia.net | CarsBikes.net | CarsBikes.org | CashIndia.net | ConsumerIndia.net | CookingIndia.net | DataIndia.net | DealIndia.net | EmailIndia.net | FirstTablet.com | FirstTourist.com | ForsaleIndia.net | IndiaBody.Com | IndiaCab.net | IndiaCash.net | IndiaModel.net | KidForum.net | OfficeIndia.net | PaysIndia.com | RestaurantIndia.net | RestaurantsIndia.net | SaleForum.net | SellForum.net | SoldIndia.com | StarIndia.net | TomatoCab.com | TomatoCabs.com | TownIndia.com
Interested to Buy Any Domain ? << Click Here >> for more details...

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


Please Help Members By Posting Answers For Below Questions

What makes a language oop?

1007


Plese get me a perfect C++ program for railway/airway reservation with all details.

3839


What is polymorphism what is it for and how is it used?

971


write knight tour problem which is present in datastructure

2597


What is abstraction in oops?

984


explain sub-type and sub class? atleast u have differ it into 4 points?

2256


What is super in oop?

1088


Can we create object of interface?

1064


Can we create object of abstract class?

1030


What are the important components of cohesion?

968


What is polymorphism and example?

980


Can we define a class within the interface?

987


What is difference between pop and oop?

1076


What is polymorphism give a real life example?

973


What is polymorphism in oops with example?

973