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

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

759


Give 10 points of differences between C & C++.

836


What is the difference between prefix and postfix versions of operator++()?

797


What are the benefits of oop in c++?

799


Is c++ high level programming language?

877


What is the use of this pointer in c++?

773


Write a program to find the Fibonacci series recursively.

814


Explain shallow copy?

780


Will rust take over c++?

775


What are the classes in c++?

821


what are Access specifiers in C++ class? What are the types?

831


What are the uses of static class data?

859


When should I use unitbuf flag?

775


Tell me difference between constant pointer and pointer to a constant.

842


Give the difference between the type casting and automatic type conversion. Also tell a suitable C++ code to illustrate both.

803