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

Is null always defined as 0(zero)?

614


Is return a keyword in c?

598


a parameter passed between a calling program and a called program a) variable b) constant c) argument d) all of the above

656


i have to apply for rbi before that i need to know the the syllabus for the entrance questions. whethet it may be aps or techinical

1842


what do the 'c' and 'v' in argc and argv stand for?

643






code for find determinent of amatrix

1513


What are the types of data types and explain?

667


Is there any demerits of using pointer?

627


Write a progarm to find the length of string using switch case?

1610


What is the use of bit field?

638


When a c file is executed there are many files that are automatically opened what are they files?

592


What is atoi and atof in c?

616


How can type-insensitive macros be created?

695


How does selection sort work in c?

620


Explain which of the following operators is incorrect and why? ( >=, <=, <>, ==)

608