write the program for prime numbers?

Answer Posted / ashwini kumar nayak

#include<stdio.h>
#include<conio.h>

void main()
{
clrscr();
int c,i,n;
c=0;
printf("Enter the number");
scanf("%d",&n);
if(n==1)
printf("Number is the special number");
else
{
for(i=2;i<n;i++)
if (n%i==0)
{
c=1;break;
}
if(c!=1)
printf("prime");
else
printf ("not a prime");
}
getch();

}

Is This Answer Correct ?    0 Yes 0 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

What is static function in c?

631


Explain what is wrong in this statement?

632


What should malloc(0) do?

613


How can I run c program?

682


How many types of errors are there in c language? Explain

570






What are the key features in c programming language?

613


What is the difference between null pointer and wild pointer?

634


How can I open files mentioned on the command line, and parse option flags?

593


PROGRAM TO WRITE CONTENTS OF 1 FILE IN REVERSE TO ANOTHER FILE,PROGRAM TO COPY 1 FILE TO ANOTHER BY SPECIFYING FILE NAMES AS COMMAND LINE

1466


Is anything faster than c?

585


What is Dynamic memory allocation in C? Name the dynamic allocation functions.

555


Write program to remove duplicate in an array?

597


why wipro wase

1827


What is a static function in c?

622


How can I automatically locate a programs configuration files in the same directory as the executable?

632