write the program for prime numbers?

Answer Posted / arafat buet

#include<stdio.h>
int main()
{
int i,n,r;
printf("enter any number:");
scanf("%d",&n);
if(n==1)
printf("not prime\n");
for(i=2;i<n;i++)
{
r=n%2;
if(r==0)
{
printf("\nnot prime\n");
break;
}
}
if(i==n)
printf("prime\n");
return 0;
}

Is This Answer Correct ?    24 Yes 19 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

write a c program to print the next of a particular no without using the arithmetic operator or looping statements?

3192


Define Spanning-Tree Protocol (STP)

649


Explain bitwise shift operators?

634


process by which one bit patten in to another by bit wise operation is? (a) masking, (b) pruning, (c) biting, (d) chopping,

1895


What is 02d in c?

640






How main function is called in c?

633


my project name is adulteration of chille powder.how can i explain it to the hr when he asks me about the project?

1125


How do you generate random numbers in C?

663


How do I send escape sequences to control a terminal or other device?

618


What is wild pointer in c?

613


Can you apply link and association interchangeably?

682


How can I invoke another program (a standalone executable, or an operating system command) from within a c program?

656


Is flag a keyword in c?

683


how can i write a program that prints out a box such that whenever i press any key8(coordinate number) on the keyboard, the box moves.

1216


Explain why can’t constant values be used to define an array’s initial size?

862