// Includes
#include "stdafx.h"
#include <iostream>
#include <math.h>
#include <stdio.h>
#include <conio.h>
using namespace std;
// GCD Function
int gcd(int m, int n)
{
int r; // Declares remainder
for (n != 0; n >> 0;) // Not Equal
{
r = m % n; // MOD Operator
m = n; // Assignment
n = r;
}
return m;
}
// Main Function
int main(int argc, _TCHAR* argv[])
{
int x, y, howMany;
cout << "\nPROGRAM GCD C++";
cout << "\nEnter how many GCD computations? ";
cin >> howMany;
In the gcd function, i needed to change the while loop to a for loop, this was the while loop.
while (n != 0) // not equal
{
r = m % n; // modulus operator
m = n; // assignment
n = r;
}
i changed it to a for loop in the above coding, but when compiling getting and error saying warning: != operator has no effect; expected operator with side effect.
how can i fix this to make a correct for loop.
also if you could tell me how to paste the actual coding page in visual studio 2012 to make it much nicer and neater that would be great.