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

Write the Program to reverse a string using pointers.

808


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

2544


Why is #define used?

1025


Explain what is the difference between null and nul?

903


Why string is used in c?

764


Explain which of the following operators is incorrect and why? ( >=, <=, <>, ==)

807


what is the role you expect in software industry?

1892


Why is python slower than c?

824


Explain what is the purpose of "extern" keyword in a function declaration?

823


What is volatile variable how do you declare it?

784


What is local and global variable in c?

864


while initialization of array why we use a[][2] why not a[2][]...?

2105


what are non standard function in c

1660


What is #include stdio h?

911


hi, which software companys will take,if d candidate's % is jst 55%?

1876