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 / 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 |
Post New Answer View All Answers
class CTest { public: void someMethod() { int nCount = 0; cout << "This is some method --> " << nCount; } }; int main() { CTest *pctest; pctest->someMethod(); return 0; } It will executes the someMethod() and displays the value too. how is it possible with our creating memory for the class . i think iam not creating object for the class. Thanks in Advance... Prakash
What is pointer in oop?
What are oops methods?
What does I oop mean?
write a program to find 2^n+1 ?
What are the benefits of interface?
What is meant by multiple inheritance?
Whats oop mean?
what's the basic's in dot net
Why is it so that we can have virtual constructors but we cannot have virtual destructors?
What are the components of marker interface?
Why multiple inheritance is not possible?
What is overriding in oops?
What are the features of oop?
can inline function declare in private part of class?