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

Why is a semicolon (;) put at the end of every program statement?

632


What should malloc(0) do? Return a null pointer or a pointer to 0 bytes?

595


Is int a keyword in c?

559


what type of questions arrive in interview over c programming?

1565


Do variables need to be initialized?

623






What is call by reference in functions?

573


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

733


How are strings stored in c?

599


Is that possible to add pointers to each other?

907


What is the use of sizeof () in c?

562


How many keywords are there in c?

596


How many types of sorting are there in c?

618


How to write a code for implementing my own printf() and scanf().... Please hep me in this... I need a guidance... Can you give an coding for c... Please also explain about the header files used other than #include...

4908


What is the difference between malloc() and calloc() function in c language?

608


Differentiate between the = symbol and == symbol?

723