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 do you know about the use of bit field?
What is a program flowchart and explain how does it help in writing a program?
Who invented bcpl language?
How can you determine the size of an allocated portion of memory?
Are pointers integers in c?
What is the sizeof () operator?
Explain what is output redirection?
What is the use of ?: Operator?
What is the difference between class and object in c?
To print the pattern 1 2 3 4 5 10 17 18 19 6 15 24 25 20 7 14 23 22 21 8 13 12 11 10 9
Draw a diagram showing how the operating system relates to users, application programs, and the computer hardware ?
Explain how do you determine a file’s attributes?
How can a process change an environment variable in its caller?
Write a program to swap two numbers without using third variable in c?
How can I list all of the predefined identifiers?