When your question is answered use !solved to mark the question as resolved.
Remember to ask specific questions, provide necessary details, and reduce your question to its simplest form. For tips on how to ask a good question use !howto ask.
4 messages · Page 1 of 1 (latest)
When your question is answered use !solved to mark the question as resolved.
Remember to ask specific questions, provide necessary details, and reduce your question to its simplest form. For tips on how to ask a good question use !howto ask.
!format
#include <stdio.h>
#include <stdlib.h>
typedef struct {
char name[32];
int HP = 2;
int ATK = 3;
} PLAYER;
int main() {
PLAYER P1;
char name;
int R1, R2, R3;
printf("\n\n\n Welcome adventurer!\n\n What is your name?\n\n");
printf(" ");
scanf("%S", &P1.name);
printf("\n Oh of course! Heard a lot about you %S!", P1.name);
while (P1.HP >= 1) {
printf("\n\n What's 1 + 1?\n");
printf("\n 1. 2\n 2. 3\n 3. 4\n\n");
printf(" ");
scanf("%d", &R1);
while (R1 < 1 || R1 > 3) {
printf("\n\n Invalid option, choose an answear from 1 to 3:\n\n\n");
printf(" ");
scanf("%d", &R1);
}
if (R1 != 1) {
P1.HP -= 1;
printf(
"\n\n Wrong Answer!\n You lose 1HP! Your current HP points are: "
"%d.\n",
P1.HP);
} else {
P1.ATQ += 1;
printf("\n\n Correct! You gain +1 ATK, current ATK is: %d.\n", P1.ATQ);
}
printf(" ");
system("pause");
printf("\n\n What's 1 + 1?\n");
printf("\n 1. 2\n 2. 3\n 3. 4\n\n");
printf(" ");
scanf("%d", &R1);
while (R1 < 1 || R1 > 3) {
printf("\n\n Invalid option, choose an answear from 1 to 3:\n\n\n");
printf(" ");
scanf("%d", &R1);
}
if (R1 != 1) {
P1.HP -= 1;
printf(
"\n\n Wrong Answer!\n You lose 1HP! Your current HP points are: "
"%d.\n",
P1.HP);
} else {
P1.ATQ += 1;
printf("\n\n Correct! You gain +1 ATK, current ATK is: %d.\n", P1.ATQ);
}
printf(" ");
system("pause");
}
printf("\n You lose the game.\n\n\n");
printf(" ");
return 0;
}
@red hornet
Please don't delete forum posts. They can be helpful to refer to later and other members can learn from them. In the future you can use !solved to close a post and mark a post as solved.