write the program for prime numbers?

Answer Posted / harpreet dhillon

#include<stdio.h> \\harpreetdhillon7@gmail.com
#include<conio.h>
void main()
{
int i,n;
clrscr();
printf("enter any number which you want to check");
scanf("%d",&n);
for(i=2;i<=n-1;i++)
{
if(n%i==0)
{
printf("not a prime number\n");
break;
}
else
{
printf("prime number\n");
break;
}
}

Is This Answer Correct ?    2 Yes 2 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

#include main() { int *p, *c, i; i = 5; p = (int*) (malloc(sizeof(i))); printf(" %d",*p); *p = 10; printf(" %d %d",i,*p); c = (int*) calloc(2); printf(" %d ",*c); }

633


Define and explain about ! Operator?

619


How pointers are declared?

567


How can I do peek and poke in c?

623


What are the key features in c programming language?

622






Why doesnt this code work?

621


Why do we need volatile in c?

750


Is malloc memset faster than calloc?

622


Explain what is wrong with this program statement? Void = 10;

768


What is the best way of making my program efficient?

573


In c language can we compile a program without main() function?

584


What are header files and explain what are its uses in c programming?

617


What is c basic?

604


How can I pad a string to a known length?

614


Is it possible to use curly brackets ({}) to enclose single line code in c program?

802