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
please explain every phase in the "SDLC" in the dotnet.
What are reserved words with a programming language?
What is the difference between typedef struct and struct?
Is linux written in c?
What are c header files?
Write a program to generate random numbers in c?
Wt are the Buses in C Language
What is the purpose of macro in C language?
What is the purpose of void in c?
Explain what is a 'locale'?
What does s c mean in text?
What is %lu in c?
Which is more efficient, a switch statement or an if else chain?
What is the difference between array and pointer in c?
How can you find the day of the week given the date?