how to find the given number is prime or not?
Answer Posted / rajamanickam.m
#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==0)
printf("the given number is prime\n");
else
printf("the given number is not prime\n");
getch();
}
| Is This Answer Correct ? | 3 Yes | 2 No |
Post New Answer View All Answers
What is the difference between text and binary modes?
What is an operator?
write a c program to do the following: a) To find the area of a triangle. b) To convert the temperature from Fahrenheit to Celsius. c) To convert the time in hours : minutes : seconds to seconds.
What is indirection? How many levels of pointers can you have?
How the c program is executed?
What is #line in c?
Explain pointer. What are function pointers in C?
How is actual parameter different from the formal parameter?
GIven a sequence of characters. How will you convert the lower case characters to upper case characters. ( Try using bit vector - sol given in the C lib -> typec.h)
simple program of graphics and their output display
How can you find the exact size of a data type in c?
What is a buffer in c?
What is the usage of the pointer in c?
Explain data types & how many data types supported by c?
Explain why c is faster than c++?