Hi guys,
I have run into a small problem. I am trying to make this "daily planner" thing and I have a question.
Code:
#include <stdio.h>
#include <string.h>
int main (void)
{
int points;
int score;
points = 5;
score = 0;
const char *key1 = "Monday";
const char *key2 = "Tuesday";
const char *key3 = "Wednesday";
const char *key4 = "Thursday";
const char *key5 = "Friday";
const char *key6 = "Saturday";
const char *key7 = "Sunday";
char day[10];
printf("Your current score is: %d.\n", score);
printf("What day is it today?\n");
scanf("%s", day);
if(strcmp (key1, day) ==0){
printf("Do this and this");
} else if (strcmp (key2, day) ==0) {
printf("Do this and this");
} else if (strcmp (key3, day) ==0) {
printf("Do this and this");
} else if (strcmp (key4, day) ==0) {
printf("Do this and this");
} else if (strcmp (key5, day) ==0) {
printf("Do this and this");
} else if (strcmp (key6, day) ==0) {
printf("Do this and this");
} else if (strcmp (key7, day) ==0) {
printf("Do this and this");
} else {
printf("You mistyped! English mother........er, do you speak it?");
}
printf("\nHave you done what you planned to accomplish?\n");
const char *answer = "yes";
char input[4];
scanf ("%s", input);
if(strcmp (input, answer)==0){
printf("Congratulations! You have scored 5 points!");
score=score+points;
}
else {
printf("\nWell, try harder then!");
}
getchar();
getchar();
return 0;
}
Firstly: how do I make the loop so that at the mistype moment the program goes back to the question "what day is it?"? should I put the whole if and if else block into a loop or just some part of it?
Secondly: I really dislike having to write out all of those if and if else statements :/ is there a way around it? I read up on it and some people said switch statements don't work but maybe there is something else?
Thirdly: is there a simple way for the program to retain the memory of my score? So that when the program terminates the score is still stored somewhere?
Thanks!