how to find the given number is prime or not?
Answer Posted / rahul tiwari
main()
{
int n,ctr=2,flag=0;
printf("enter the number to be checked\n");
scanf("%d",&n);
for(ctr=2;ctr<=n/2;ctr++)
{
if(n%ctr==0)
{
flag=1;
break;
}
}
if(flag==1)
printf("the given number is prime\n");
else
printf("the given number is not prime\n");
flag=9
getch();
}
| Is This Answer Correct ? | 8 Yes | 7 No |
Post New Answer View All Answers
What is structure in c language?
How can I use a preprocessorif expression to ?
Explain what is the concatenation operator?
What are loops c?
Tell me the use of bit field in c language?
Explain how to reverse singly link list.
How are structure passing and returning implemented?
a) Identify the following declarations. Ex. int i (integer variable) float a[l0](array of 10 real nos) int (*f())() void *f int (*f()) [] void *f int f[] [] [] char *(*f) () int (*f[]) [] float(*f) [] [] float **f int ******f
How can I insert or delete a line (or record) in the middle of a file?
What are dangling pointers? How are dangling pointers different from memory leaks?
Why static variable is used in c?
FILE PROGRAMMING
using for loop sum 2 number of any 4 digit number in c language
what do the 'c' and 'v' in argc and argv stand for?
How many main () function we can have in a project?