- #1
Vishalrox
- 20
- 0
Wanted help in c++ !
Program to print the number of prime numbers between two user given numbers.
MY ATTEMPT TO SOLUTION :
I hv found how to print the prime numbers between two given numbers but couldn't print the number of prime numbers between two given numbers.
#include<iostream.h>
#include<conio.h>
void main()
{
int n,x,i,j;
cout<<"Enter the lower range";
cin>>n;
cout<<"Enter the upper range";
cin>>x;
for(i = n;i<=x;i++)
{
for(j = 2;j<=i-1;j++)
{
if(i % j !== 0)
{
cout<<i;
cout<<"\n";
}
}
}
getch();
}
Program to print the number of prime numbers between two user given numbers.
MY ATTEMPT TO SOLUTION :
I hv found how to print the prime numbers between two given numbers but couldn't print the number of prime numbers between two given numbers.
#include<iostream.h>
#include<conio.h>
void main()
{
int n,x,i,j;
cout<<"Enter the lower range";
cin>>n;
cout<<"Enter the upper range";
cin>>x;
for(i = n;i<=x;i++)
{
for(j = 2;j<=i-1;j++)
{
if(i % j !== 0)
{
cout<<i;
cout<<"\n";
}
}
}
getch();
}