Write a program to find whether the given number is prime or
not?
Answer Posted / nikhilreddy gujjula
#include<stdio.h>
#include<conio.h>
void main()
{
int prime=1;
int n,i;
printf("enter a number");
scanf("%d",&n);
if(i=2;i<=n/2;i++)
{
if((n%i)==0)
{
prime=0;
break;
}
}
if(prime==1)
{
printf("%d is a prime number",n);
}
else
{
printf("%d is not a prime number",n);
}
getch();
}
Is This Answer Correct ? | 5 Yes | 5 No |
Post New Answer View All Answers
How many types of operator or there in c?
What is the purpose of scanf() and printf() functions?
What is the most efficient way to count the number of bits which are set in an integer?
Explain what are preprocessor directives?
What is the meaning of c in c language?
GIVEN A FLOATING POINT NUMBER HOW IS IT ACTUALLY STORED IN MEMORY ? CAN ANYONE EXPLAIN?? THE 32 BIT REPRESENTATION OF A FLOATING POINT NUMBER ALLOTS: 1 BIT-SIGN 8 BITS-EXPONENT 23 BITS-MANTISSA
how can I convert a string to a number?
Why c is procedure oriented?
Which header file is essential for using strcmp function?
What oops means?
What is the use of getchar() function?
What is substring in c?
Define macros.
a c code by using memory allocation for add ,multiply of sprase matrixes
Explain what are the standard predefined macros?