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



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

What are objects in oop?

803


Will I be able to get a picture in D drive to the c++ program? If so, help me out?

1847


What is meant by multiple inheritance?

922


What do you mean by overloading?

772


What is class encapsulation?

796






What is constructor overloading in oop?

818


What is the importance of oop?

810


What is the point of polymorphism?

751


IS IT NECESSARY TO INITIALIZE VARIABLE? WHAT IF THE INSTANCE VARIABLE IS DECLARED final ? IS IT NECESSARY TO INITIALIZE THE final VARIABLE AT THE TIME OF THEIR DECLARATION?

1777


Why polymorphism is used in oops?

768


What does I oop mean?

810


Is data hiding and abstraction same?

742


Why do we need oop?

856


What does sksksk mean in text slang?

1801


What is the fundamental idea of oop?

822