write the program for prime numbers?

Answer Posted / karthik

#include<stdio.h>
#include<conio.h>
void main()
{
int n,c=0,i;
clrscr();
printf("enter any number");
scanf("%d",&n);
for(i=1;i<=n;i++)
{
if(n%i==0)
c++;
}
(c==2)? printf("%d is a prime number",n):
printf("%d is not a prime number",n);
getch();
}

Is This Answer Correct ?    2 Yes 0 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

What is the use of ?

622


What is NULL pointer?

673


Explain 'bit masking'?

650


what are the facialities provided by you after the selection of the student.

1658


How can I generate floating-point random numbers?

602






Which one would you prefer - a macro or a function?

602


Explain 'bus error'?

557


What are the functions to open and close file in c language?

725


What is the condition that is applied with ?: Operator?

659


How do you define structure?

563


How would you rename a function in C?

616


#include main() { enum _tag{ left=10, right, front=100, back}; printf("left is %d, right is %d, front is %d, back is %d",left,right,front,back); }

712


Why do we write return 0 in c?

551


What is null in c?

598


What are the 5 types of organizational structures?

548