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 are high level languages like C and FORTRAN also known as?
Can a variable be both constant and volatile?
What is variable initialization and why is it important?
What are the types of functions in c?
typedef enum { html, java, javascript, perl, cgi } lang;The above statement defines a : a) Union b) User defined type c) Enumerated variable d) none
What is omp_num_threads?
What are the disadvantages of external storage class?
Is register a keyword in c?
What is a char c?
Difference between pass by reference and pass by value?
How can I swap two values without using a temporary?
What is the purpose of clrscr () printf () and getch ()?
Is c is a middle level language?
Why is python slower than c?
What is the right way to use errno?