write the prime no program in c++?

Answer Posted / indu

#include<stdio.h>
#include<conio.h>
main()
{
int n,s=0,i;
clrscr();
printf("Enter the number\n");
scanf("%d",&n);
for(i=2;i<n/2;i++)
{
if(n%i==0)
s++;
}
if(s>=1)
printf("%d is not prime",n);
else
printf("%d is prime",n);
getch();
}
ill execute it .it's cent percent correct.

Is This Answer Correct ?    40 Yes 22 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

What are its advantages and disadvantages of multiple inheritances (virtual inheritance)?

601


Is multimap sorted c++?

557


What is setbase c++?

621


What is the purpose of templates in c++?

563


What do you mean by funtion prototype?

580






Does there exist any other function which can be used to convert an integer or a float to a string?

649


Why do we learn c++?

527


Does c++ vector allocate memory?

530


Can constructor be static in c++?

639


What is scope operator in c++?

565


What is the difference between containment and delegation?

700


What is unary operator? List out the different operators involved in the unary operator.

586


What is difference between n and endl in c++?

584


State the difference between pre and post increment/decrement operations.

606


what are the events occur in intr activated on interrupt vector table

1178