Sunday, March 17, 2013

C++ program to find prime numbers in a given range

10:11 AM

Write a C++ program to print all the prime numbers with in the given range



#include<iostream>
#include<iomanip>
using namespace std;

int main(){
int num,i,count,n;
cout << "Enter max range: ";
cin >> n;
for(num = 1;num<=n;num++){
count = 0;
for(i=2;i<=num/2;i++){
if(num%i==0){
count++;
break;
}
}

if(count==0 && num!= 1)
cout << num << setw(3);
}
system("pause");
return 0;
}

C++ program to find prime numbers in a given range 





---------------------------------------------------------------------------------------------
---------------------------------------------------------------------------------------------




---------------------------------------------------------------------------------------------
---------------------------------------------------------------------------------------------



Program in C++ to find the prime number in given range
Write a C++ program to find prime numbers between 1 to 100
Prime numbers in a range - C++
Program to find the prime numbers between a given range
Write a program to print all the prime numbers with in the given range
C++ program to find prime numbers between two numbers
C++ program to find sum of prime numbers
C++ Program to Find Prime Numbers in a given Range

Written by

We are one of the initiators of the development of information technology in understanding the need for a solution that is familiar and close to us.

0 comments:

Post a Comment

 

© 2013 Klick Dev. All rights resevered.

Back To Top