Hey, I new to C++ and I was trying to make a program that solved a maths problem for me (I wanted to find out how many times the anwer would be a positive integer, given that n is a positive integer):
n+17
------ // That's a dividing sign
n-7
I tried a few methods, but couldn't get what I want.
Here's my latest attempt:
Code:
#include <stdafx.h>
#include <iostream>
using namespace std;
float main()
{
float x, y, z;
for ( float n = 0; n < 1000; n = n + 14){
x = n - 7;
y = n + 17;
z = n / x;
if (z > 0){
cout<<y <<endl;
n = n - 17;
x = x - 7;
}
else {
cout<<y <<" is not a positive integer" <<endl;
}
}
cin.get();
return 0;
}
I'm using the Visual C++ Express 2005 program if tht helps. I thought I might make the variables floats to make sure the decimals aren't truncated in an int thinking the program will see them as positive integers anyway. Thanks!