Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

QUESTION 1 Write down the exact step-by-step execution of this code and it's output, then upload your answer. Your instructor will mark your response. Full

image text in transcribed
QUESTION 1 Write down the exact step-by-step execution of this code and it's output, then upload your answer. Your instructor will mark your response. Full marks will be awarded for writing down the steps in correct order describing the exact execution of the code. Partial marks may be awarded for submissions that are missing minor details. 01 #include 02 03 #define INITIAL_HEALTH 100 04 #define NAME_LENGTH 10 05 06 struct Hero 07 { 08 char name [NAME_LENGTH + 1] ; 09 int health 10 int strength; 11 int shield; 12 } 13 14 struct Hero attack (struct Hero* hi, struct Hero* h2) 15 { 16 struct Hero result; 17 18 while (hi->health > 0 46 h2->health > 0) 19 20 hi->health -= h2->strength - hi->shield; 21 h2->health -= h1->strength - h2->shield; 22 23 24 if (hi->health health) 25 26 result = *h1; 27 28 else 29 30 result = *h2; 31 32 33 return result; 34 } 35 36 int main (void) 37 { 38 struct Hero herol = { {'N', 'i', 'n' , 'j', 'a', '\\' } , INITIAL_HEALTH, 150, 20 }; 39 struct Hero hero2 = { "Enigma", INITIAL_HEALTH, 75, 50 ) ; 40 41 struct Hero winner = attack (cherol, chero2) ; 42 43 puts ("Game Over") ; 44 printf ("The winner is *s", winner .name) ; 45 46 return 0; 47

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Financial management theory and practice

Authors: Eugene F. Brigham and Michael C. Ehrhardt

12th Edition

978-0030243998, 30243998, 324422695, 978-0324422696

Students also viewed these Programming questions