Hello again. This time I had done a prog that will print out prime number, even number and also odd number from specific intervals. My problems were the output for prime number and even number were not printed out at all. Hope to see some good comments about my problems. Thanks in advance!
[code]
#include <iostream>
#include <cmath>
using namespace std;
int main()
{ int int1,int2,i,j,k;
cout << " Please enter two integers ";
cin >> int1 >> int2;
cout << " the odd numbers between the integers are : ";
for(i=int1; int1<int2; int1++){
if(int1%2!=0){
cout << int1 << " ";
}
if(int1%2==0)continue;
}
cout << endl;
cout << " The even number between the integers are : ";
for(j=int1; int1<int2; int1++){
if(int1%2==0){
cout << int1 << " ";
}
if(int1%2!=0)continue;
}
cout << endl;
cout << " The prime number between the integers are : ";
for(k=int1; int1<int2; int1++){
int1%(int1-1);
if(int1%(int1-1)==0)continue;
if(int1%(int1-1)!=0){
cout << int1 << " ";
}
}
for(i=int1; int1<int2; int1++){
Here you are comparing and increasing int1 when you should be comparing and increasing i. When you reach the other loops, int1 < int2 is already true, so the body of the loops do not execute.