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


Please Help Members By Posting Answers For Below Questions

How many types of operator or there in c?

860


What is the purpose of scanf() and printf() functions?

955


What is the most efficient way to count the number of bits which are set in an integer?

848


Explain what are preprocessor directives?

849


What is the meaning of c in c language?

845


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

1698


how can I convert a string to a number?

842


Why c is procedure oriented?

812


Which header file is essential for using strcmp function?

1237


What oops means?

787


What is the use of getchar() function?

891


What is substring in c?

905


Define macros.

1056


a c code by using memory allocation for add ,multiply of sprase matrixes

2562


Explain what are the standard predefined macros?

910