0

i need little help of urs in the above code, RightFrom Function is perfectly working but there is a logic bug in LeftFrom Function.
when i m sending North as argument the result from LeftFrom is -1 but i need 0. help me to solve this issue.

#include <iostream>
using namespace std;
enum direction{
	North,
	East,
	South,
	West,
};

direction RightFrom(direction d){
	return direction((d+1) % 4);
}

direction LeftFrom(direction d){
	return direction((d-1) % 4);
}

void main(){
	cout << RightFrom(West) << endl; // West = 4 and it will output 0 as required
	
	cout << LeftFrom(North) << endl; // North = 0 and it will output -1 ( but i need the result 0)	
}
3
Contributors
2
Replies
3
Views
8 Years
Discussion Span
Last Post by Ancient Dragon
This question has already been answered. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.