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 is the difference between function overloading and operator overloading?

579


Why is c++ is better than c?

519


Which command properly allocates memory a) char *a=new char[20]; b) char a=new char[20]; c) char a=new char(20.0);

621


What is a buffer c++?

587


Can constructor be private in c++?

610






How can you quickly find the number of elements stored in a dynamic array? Why is it difficult to store linked list in an array?

565


Which programming language is best?

558


Explain how a pointer to function can be declared in C++?

584


Write about the role of c++ in the tradeoff of safety vs. Usability?

606


What is the use of cmath in c++?

593


What is the basic concept of c++?

580


What are the stages in the development cycle?

577


Describe delete operator?

626


What is virtual base class?

575


write a programme to get a character and thier ASCII value

2599