Please write this code and show me the output

Computer Networking: A Top-Down Approach (7th Edition)
7th Edition
ISBN:9780133594140
Author:James Kurose, Keith Ross
Publisher:James Kurose, Keith Ross
Chapter1: Computer Networks And The Internet
Section: Chapter Questions
Problem R1RQ: What is the difference between a host and an end system? List several different types of end...
icon
Related questions
Question
Please write this code and show me the output
#include <stdio.h>
#define NROWS 8
#define NCOLS 8
#define FALSE O
#define TRUE
1
main ()
int knight_row, knight_co%;
int line, row, col, i, j;
int filled;
printf("Chess Knight Program\n");
/****
/* Read knight_row, knight_col
/* until they are both in range. * /
/******
****************
do {
printf("Enter knight's coordinates: ");
scanf ("%d %d", &knight_row, &knight_col);
) while ((knight_row < 1)
||
(knight_row > NROWS) ||
(knight_col > NCOLS));
(knight_col < 1)
/* Print 2 * NROWS +1 rows
/******
for (line = 1; line <= 2
row = line / 2;
if (line % 2 != 0) (
/***
/* Odd line number: print one row of +---+'s
NROWS + 1; line++) (
printf("+") ;
for (col = 1; col <= NCOLS; col++)
printf("---+");
printf("\n" ) ;
else {
/***
/* Even line number: print one row of vertical*/
/* bars, with '*'s and a K where appropriate. */
/**************
*********/
******* /
**********
printf("|");
for (col = 1; col <= NCOLS; col++) (
filled = FALSE;
/*****
/*
*****
If a K belongs here, print it.
* /
if ((row == knight_row) && (col == knight_col)) (
printf(" K |");
filled = TRÙE;
continue;
********** /
Transcribed Image Text:#include <stdio.h> #define NROWS 8 #define NCOLS 8 #define FALSE O #define TRUE 1 main () int knight_row, knight_co%; int line, row, col, i, j; int filled; printf("Chess Knight Program\n"); /**** /* Read knight_row, knight_col /* until they are both in range. * / /****** **************** do { printf("Enter knight's coordinates: "); scanf ("%d %d", &knight_row, &knight_col); ) while ((knight_row < 1) || (knight_row > NROWS) || (knight_col > NCOLS)); (knight_col < 1) /* Print 2 * NROWS +1 rows /****** for (line = 1; line <= 2 row = line / 2; if (line % 2 != 0) ( /*** /* Odd line number: print one row of +---+'s NROWS + 1; line++) ( printf("+") ; for (col = 1; col <= NCOLS; col++) printf("---+"); printf("\n" ) ; else { /*** /* Even line number: print one row of vertical*/ /* bars, with '*'s and a K where appropriate. */ /************** *********/ ******* / ********** printf("|"); for (col = 1; col <= NCOLS; col++) ( filled = FALSE; /***** /* ***** If a K belongs here, print it. * / if ((row == knight_row) && (col == knight_col)) ( printf(" K |"); filled = TRÙE; continue; ********** /
/*
/*************
If a '* belongs here, print it.
*****
for (i = -2; i <= 2; i++) {
for (j = -2; j <= 2; j++) {
if ((i == j) || (i == -j) || (i == 0) || (j
if ((knight_row + i == row) && (knight_co1 +j = col)) (
printf (" * ");
filled = TRUE;
== 0)) continue;
/*****
******* /
***
*****
Print a vertical bar if slot not filled.
*/
/**
********/
**********************
if (!filled) printf("
|");
printf("\n");
return 0;
Transcribed Image Text:/* /************* If a '* belongs here, print it. ***** for (i = -2; i <= 2; i++) { for (j = -2; j <= 2; j++) { if ((i == j) || (i == -j) || (i == 0) || (j if ((knight_row + i == row) && (knight_co1 +j = col)) ( printf (" * "); filled = TRUE; == 0)) continue; /***** ******* / *** ***** Print a vertical bar if slot not filled. */ /** ********/ ********************** if (!filled) printf(" |"); printf("\n"); return 0;
Expert Solution
steps

Step by step

Solved in 3 steps with 1 images

Blurred answer
Recommended textbooks for you
Computer Networking: A Top-Down Approach (7th Edi…
Computer Networking: A Top-Down Approach (7th Edi…
Computer Engineering
ISBN:
9780133594140
Author:
James Kurose, Keith Ross
Publisher:
PEARSON
Computer Organization and Design MIPS Edition, Fi…
Computer Organization and Design MIPS Edition, Fi…
Computer Engineering
ISBN:
9780124077263
Author:
David A. Patterson, John L. Hennessy
Publisher:
Elsevier Science
Network+ Guide to Networks (MindTap Course List)
Network+ Guide to Networks (MindTap Course List)
Computer Engineering
ISBN:
9781337569330
Author:
Jill West, Tamara Dean, Jean Andrews
Publisher:
Cengage Learning
Concepts of Database Management
Concepts of Database Management
Computer Engineering
ISBN:
9781337093422
Author:
Joy L. Starks, Philip J. Pratt, Mary Z. Last
Publisher:
Cengage Learning
Prelude to Programming
Prelude to Programming
Computer Engineering
ISBN:
9780133750423
Author:
VENIT, Stewart
Publisher:
Pearson Education
Sc Business Data Communications and Networking, T…
Sc Business Data Communications and Networking, T…
Computer Engineering
ISBN:
9781119368830
Author:
FITZGERALD
Publisher:
WILEY