Write a program to find whether the given number is prime or
not?

Answer Posted / sudha

#include<stdio.h>
#include<conio.h>
void main()
{
int isprime=1;
int n,i;
printf("enter a number");
scanf("%d",&n);
if(i=2;i<=n/2;i++)
{
if((n%i)==0)
{
isprime=0;
break;
}
}
if(isprime==1)
{
printf("%d is a prime number",n);
}
else
{
printf("%d is not a prime number",n);
}
getch();
}

Is This Answer Correct ?    18 Yes 5 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

write a program to convert a expression in polish notation(postfix) to inline(normal) something like make 723+* (2+3) x 7 (not sure) just check out its mainly printing expression in postfix form to infix.

3767


i want to switch my career from quailty assurance engineering to development kindly guide me from which programming language its better for me to start plz refer some courses or certifications too i have an experience of 1.5 yrs in QA field.Kindly guide me

1703


what is the syallabus of computer science students in group- 1?

2109


Why is main function so important?

883


Why do we use c for the speed of light?

855


Define Spanning-Tree Protocol (STP)

913


What is union in c?

888


What is scanf () in c?

872


Why is it that not all header files are declared in every C program?

951


.main() { char *p = "hello world!"; p[0] = 'H'; printf("%s",p); }

1007


Why string is used in c?

791


What is the best way to comment out a section of code that contains comments?

1109


Write a program to reverse a linked list in c.

906


Write a code to generate divisors of an integer?

853


What is array of pointers to string?

840