From c693ca23875ed5e12fedc78ea5c3f813522655c7 Mon Sep 17 00:00:00 2001 From: Monalika Date: Wed, 26 May 2021 21:13:34 +0530 Subject: [PATCH] Create Determine the color of chess square.cpp --- Determine the color of chess square.cpp | 30 +++++++++++++++++++++++++ 1 file changed, 30 insertions(+) create mode 100644 Determine the color of chess square.cpp diff --git a/Determine the color of chess square.cpp b/Determine the color of chess square.cpp new file mode 100644 index 0000000..5aca614 --- /dev/null +++ b/Determine the color of chess square.cpp @@ -0,0 +1,30 @@ +#include +#include +using namespace std; + +int main() +{ + char string[10], x; + cout << "Enter the coordinates of the square, \ + \nthe first coordinate A to H and second coordinate 1 to 8: "; + cin.getline(string, 10); + x = string[0]; + x = tolower(x); + string[0] = x; + if (string[0] == 'a' || string[0] == 'c' || string[0] == 'e' || string[0] == 'g') + { + if (string[1] == '1' || string[1] == '3' || string[1] == '5' || string[1] == '7') + cout << "Black square"; + else + cout << "White square"; + } + else + { + if (string[1] == '1' || string[1] == '3' || string[1] == '5' || string[1] == '7') + cout << "white square"; + else + cout << "Black square"; + } + + return 0; +}