I have a minor problem.
I want to set an integer to zero when it easy equal to another integer, but it seems that the program for some reason won't set the integer to zero.
Here is the example of that code:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15
#include <iostream>
usingnamespace std;
int main () {
int n = 2;
int r = 2;
if(n==r)
n++;
r*0;
cout << " n is " << n << endl;
cout << " r is " << r << endl;
}
What am I doing wrong, it should say that "n is 3" and "r is 0".
#include<iostream>
usingnamespace std;
int main ()
{
int n=2;
int r=0;
do{
if(n==r)
n++;
r = r*0;
if (n<=10)
cout<<"n je " << n << endl;
if (r<n)
r++;
if (r<=n)
cout << "r je " << r <<endl;
}while(n<10 || r<10);
}