
Computer Networking: A Top-Down Approach (7th Edition)
7th Edition
ISBN: 9780133594140
Author: James Kurose, Keith Ross
Publisher: PEARSON
expand_more
expand_more
format_list_bulleted
Question
Please write this code and show me the output

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;
********** /

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

This question has been solved!
Explore an expertly crafted, step-by-step solution for a thorough understanding of key concepts.
Step by stepSolved in 3 steps with 1 images

Knowledge Booster
Similar questions
- (Intro to Python) Include your name and program output in a comment at the top of the script you submit. Note: upload a script for example scriptname.py (do not copy-paste the interactive mode commands) Write complete code that asks the user to input two integer numbers. Define and call a function called remainder that takes two parameters x and y and prints the remainder when x is divided by y. When y is zero, it should not perform the division and instead print "cannot divide by zero" to prevent the runtime error. Sample output is as follows: Enter a number: x Enter another number: y Remainder of x divided by y is z (you'll fill in the values of x, y and z)arrow_forward-I need someone to help me fix my code. Whenever I input my code and run it, I don't get an error but I also don't get an output. -Here is the guide: Using Python, use import sys to create a program Create a program change.py, that has a function that takes 5 arguments that correspond to the number of $1 dollar bills, quarters, dimes, nickels, andpennies, respectively. Calculate the total value of that change, and print "The total value of your change is $x" where x is equal to the total value. -Here is what I have so far: import sys dollar = int(sys.argv[1])quarters = int(sys.argv[2])dimes = int(sys.argv[3])nickels = int(sys.argv[4])pennies = int(sys.argv[5]) total = dollar*1 + quarters*0.25 + dimes*0.10 + nickels*0.05 + pennies*0.01 print("Total value of your change is $",total) python3 change.py 4 7 8 9 7 -Please provide a revised codearrow_forwardC program. I attached instructions. Can you copy and paste the code, please? So much appreciation.arrow_forward
arrow_back_ios
arrow_forward_ios
Recommended textbooks for you
- Computer Networking: A Top-Down Approach (7th Edi...Computer EngineeringISBN:9780133594140Author:James Kurose, Keith RossPublisher:PEARSONComputer Organization and Design MIPS Edition, Fi...Computer EngineeringISBN:9780124077263Author:David A. Patterson, John L. HennessyPublisher:Elsevier ScienceNetwork+ Guide to Networks (MindTap Course List)Computer EngineeringISBN:9781337569330Author:Jill West, Tamara Dean, Jean AndrewsPublisher:Cengage Learning
- Concepts of Database ManagementComputer EngineeringISBN:9781337093422Author:Joy L. Starks, Philip J. Pratt, Mary Z. LastPublisher:Cengage LearningPrelude to ProgrammingComputer EngineeringISBN:9780133750423Author:VENIT, StewartPublisher:Pearson EducationSc Business Data Communications and Networking, T...Computer EngineeringISBN:9781119368830Author:FITZGERALDPublisher:WILEY

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 Engineering
ISBN:9780124077263
Author:David A. Patterson, John L. Hennessy
Publisher:Elsevier Science

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
Computer Engineering
ISBN:9781337093422
Author:Joy L. Starks, Philip J. Pratt, Mary Z. Last
Publisher:Cengage Learning

Prelude to Programming
Computer Engineering
ISBN:9780133750423
Author:VENIT, Stewart
Publisher:Pearson Education

Sc Business Data Communications and Networking, T...
Computer Engineering
ISBN:9781119368830
Author:FITZGERALD
Publisher:WILEY