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
What does *p++ do?
Why is event driven programming or procedural programming, better within specific scenario?
What are header files in c?
how to find binary of number?
Difference between Shallow copy and Deep copy?
PLS U SENS ME INTERVIEW O. MY EMAIL ADD, SOFIYA.SINGH@GMAIL.COM
What is typedef struct in c?
What is the use of a semicolon (;) at the end of every program statement?
Create a simple code fragment that will swap the values of two variables num1 and num2.
What is meant by keywords in c?
What is difference between constant pointer and constant variable?
What is the use of ?: Operator?
a value that does not change during program execution a) variabe b) argument c) parameter d) none
How can I copy just a portion of a string?
Using which language Test cases are added in .ptu file of RTRT unit testing???