how to find the given number is prime or not?
Answers were Sorted based on User's Feedback
Answer / 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 |
Answer / 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 |
Answer / 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 |
Answer / arunkumar mt
#include<stdio.h>
#include<conio.h>
#include<math.h>
void main()
{
int i,n,flag=0;
clrscr();
printf("enter a number\n");
scanf("%d",&n);
for(i=2;i<=sqrt(n);i++)
{
if(n%i==0)
{
flag=1;
break;
}
}
if(flag==0)
{
printf("given number %d is prime",n);
}
else
{
printf("given number %d is not prime",n);
}
getch();
}
| Is This Answer Correct ? | 2 Yes | 3 No |
Answer / 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 |
Answer / amit kumar
#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 ? | 2 Yes | 5 No |
can any one please explain, how can i access hard disk(physical address)? it is possible by the use of far,near or huge pointer? if yes then please explain......
What is the difference between formatted&unformatted i/o functions?
How to convert decimal to binary in C using recursion??
what is the use of operator ^ in C ? and how it works?
HOW TO FIND OUT THE RREVERS OF A GIVEN DIGIT NUMBER IF IT IS INPUT THROUGH THE KEYBORD BY USING C LANGUAGE
how can f be used for both float and double arguments in printf? Are not they different types?
What is context in c?
out put of printf(“%d”,printf(ram));
‘ C’ PROGRAME TO SHOW THE TYPE OF TRANGLE BY ACCEPTING IT’S LENGTH .
What is the difference between %d and %*d in C
Write a C program to print 1 2 3 ... 100 without using loops?
What is the difference between union and anonymous union?