What will the logic of print a chess in c language. | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
0

What will the logic of print a chess in c language.

** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** it is chess of 3*3 .write code in c for n*n chess.

17th Oct 2017, 6:17 AM
RAHUL KUMAR
RAHUL KUMAR - avatar
5 Answers
+ 2
for(unsigned i = 0; i < n; ++i){ for(unsigned j = 0; j < n; ++j){ if(2 - i&1 - j&1) printf("**"); else printf(" "); } putchar('\n'); for(unsigned j = 0; j < n; ++j){ if(2 - i&1 - j&1) printf("**"); else printf(" "); } putchar('\n'); }
18th Oct 2017, 12:50 PM
Baptiste E. Prunier
Baptiste E. Prunier - avatar
+ 1
edited :)
18th Oct 2017, 2:41 PM
Baptiste E. Prunier
Baptiste E. Prunier - avatar
+ 1
Hum ... Strange, it worked when I used it on Sololearn
18th Oct 2017, 6:37 PM
Baptiste E. Prunier
Baptiste E. Prunier - avatar
0
I think your code is not right. Please check your condition and check your code
18th Oct 2017, 1:22 PM
RAHUL KUMAR
RAHUL KUMAR - avatar
0
no ,when I am trying with 3 I want same pattern as I draw in question. but ur code is not drawing it .
18th Oct 2017, 2:47 PM
RAHUL KUMAR
RAHUL KUMAR - avatar