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
How many types of functions are there in c?
int main() { Int n=20,i; For(i=0;i<=n;i--) { Printf(“-“); Return 0;
Differentiate between functions getch() and getche().
What is const volatile variable in c?
Write a program to implement queue.
What is calloc malloc realloc in c?
Is swift based on c?
What does d mean?
How can I discover how many arguments a function was actually called with?
What does the c preprocessor do?
Tell me when would you use a pointer to a function?
How do you convert strings to numbers in C?
Explain the advantages and disadvantages of macros.
how can i write a program that prints out a box such that whenever i press any key8(coordinate number) on the keyboard, the box moves.
What does the error 'Null Pointer Assignment' mean and what causes this error?