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.

Answers were Sorted based on User's Feedback



How can i write a code in c# to take a number from the user and then find all the prime numbers til..

Answer / kumar gaurav

void main()
{
int num=0, i=0;
printf("Enter the number to ckeck");
scanf("%d",&num);
for (i=2;i<num;i++)
{
if (num%i==0)
{
printf("Number is not prime");
break;
}
}
if (i==num)
{
printf("Number is prime");
}
getch();
}

Is This Answer Correct ?    10 Yes 1 No

How can i write a code in c# to take a number from the user and then find all the prime numbers til..

Answer / 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

How can i write a code in c# to take a number from the user and then find all the prime numbers til..

Answer / guest

for(i=0;i<n;i++)
{
if(i==1||i==2||i==3||i==5||i==7)
{
printf("No is prime");
}
else if(i%2==0&&i%3==0&&i%5==0&&i%7==0)
{
printf("No is prime");
}
else
printf("No is not prime");
}

Is This Answer Correct ?    5 Yes 9 No

How can i write a code in c# to take a number from the user and then find all the prime numbers til..

Answer / anjali

while(num>0)
{
if(num%2==1)
printf("num is prime value");
}

Is This Answer Correct ?    1 Yes 10 No

Post New Answer

More OOPS Interview Questions

What is the problem with multiple inheritance?

0 Answers  


What is and I oop mean?

0 Answers  


Can java compiler skips any statement during compilation time?

0 Answers  


Why is oop useful?

0 Answers  


what is the difference between class and structure in C++?

9 Answers   Aspire, IBS, TCS,


Write a C++ program to conduct an election of a mayor.Declare a class ELECTION With the following specification: Data member: Name 25 character Age Integer symbol 1 character Member functions: To accept data for 20 contestant To accept symbol as voting from 100 voters. To declare the winner and the loser.

1 Answers   Global Academy, Infotech,


create a c++ program that will ask 10 numbers and display their sum using array.

1 Answers  


When will a constructor executed?

5 Answers   TCS,


When not to use object oriented programming?

0 Answers  


What is the difference between encapsulation and polymorphism?

0 Answers  


OOP'S advantages of inheritance include:

1 Answers   Infosys,


what is the virtual function overhead, and what is it used for ? i hope i can get and appropriate answers, thanks a lot....

6 Answers  


Categories