how to find the given number is prime or not?
Answer Posted / shweta
#include<stdio.h>
#include<conio.h>
void 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=0;
getch();
}
| Is This Answer Correct ? | 2 Yes | 5 No |
Post New Answer View All Answers
How can I remove the leading spaces from a string?
How we can insert comments in a c program?
When should I declare a function?
How do you do dynamic memory allocation in C applications?
Linked lists -- can you tell me how to check whether a linked list is circular?
Hai sir, I had planned to write the NIC scientific engineer exam , plz post the sample question......
what do you mean by inline function in C?
Does c have circular shift operators?
List the difference between a "copy constructor" and a "assignment operator"?
What are the advantage of c language?
Explain what are the advantages and disadvantages of a heap?
What is the use of void pointer and null pointer in c language?
What does #pragma once mean?
Are comments included during the compilation stage and placed in the EXE file as well?
What would the following code segment printint k = 8;docout << "k = " << k << " ";while k++ < 5; a) 13 b) 5 c) 8 d) pointers