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
What is destructor in oop?
Why multiple inheritance is not possible?
i=20;k=0;
for(j=1;k-i;k+=j<10?4:3)
{
cout< What is the full form of oops? What do you mean by Encapsulation? what is graphics What is advantage of inheritance? Write a java applet that computes and displays the squares
of values between 25 and 1 inclusive and displays them in a
TextArea box
What is encapsulation in ict? What is new keyword in oops? What is encapsulation process? What is use of overloading? Will I be able to get a picture in D drive to the c++
program? If so, help me out? What is coupling in oop? is there any choice in opting subjects like 4 out of 7