how to find the given number is prime or not?
Answer Posted / shrikanth s.hallikhed
#include<stdio.h>
#include<conio.h>
#include<math.h>
void main()
{
int n,flag=0,ctr;
printf("enter the number to be checked\n");
scanf("%d",&n);
for(ctr=2;ctr<=sqrt(n);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");
getch();
}
| Is This Answer Correct ? | 3 Yes | 3 No |
Post New Answer View All Answers
Explain the advantages and disadvantages of macros.
What would the following code segment printint k = 8;docout << "k = " << k << " ";while k++ < 5; a) 13 b) 5 c) 8 d) pointers
What is the use of function overloading in C?
What is meant by errors and debugging?
What is the purpose of sprintf() function?
how to count no of words,characters,lines in a paragraph.
Explain how do you override a defined macro?
How would you obtain the current time and difference between two times?
Write a program to reverse a linked list in c.
Explain how do you determine the length of a string value that was stored in a variable?
What are the advantages of c preprocessor?
What is #include cctype?
What is meant by high-order and low-order bytes?
int i=3; this declaration tells the C compiler to a) reserve space in memory to hold the integer value b) associate the name i with this memory location c) store the value 3 at this location d) all the above
What is the code for 3 questions and answer check in VisualBasic.Net?