write the prime no program in c++?

Answer Posted / pramod k sharma

#include<iostream.h>
#include<conio.h>
main()
{
int n,i,f=1;
cout<<"enter any no to check prime";
cin>>n;
for(i=2;i<n;i++)
{
if(n%i==0)
k=2;
}
if(k==2)
cout<<"the no is not prime"<<endl;
else
cout<<"the no is prime";
}
getch();

Is This Answer Correct ?    14 Yes 32 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

How does a C++ structure differ from a C++ class?

628


What is the best c++ book for beginners?

578


Describe the process of creation and destruction of a derived class object?

643


What is the average salary of a c++ programmer?

549


What character terminates all character array strings a) b) . c) END

676






How do you decide which integer type to use?

579


Explain the difference between new() and malloc() in c++?

625


What is the difference between structure and class?

563


Which c++ compiler is best?

590


How would you use the functions memcpy(), memset(), memmove()?

625


Of the numbers 12 23 9 28 which would be at the top of a properly implemented maxheap a) 28 b) 9 c) Any of them could be

933


How does java differ from c and c++?

546


Can a list of string be stored within a two dimensional array?

579


Can I learn c++ in a week?

583


What is pointer in c++ with example?

522