Here is a new code without goto! Yes! but it always seems to generate 41 for me. I looked up ways to generate numbers and to make a limit but i can only find very complicated algorithms. I fixed the scanf problem, although not in the best way probably.
Code:
#include<stdio.h>
#include<stdlib.h>
int main(void)
{
int a; int b;
printf("Welcome to the number guessing game! Press enter to start:\n");
getchar();
a = rand();
start_of_game:
printf("Guess a number \n", a);
scanf("%d", &b);
while (b != a)
{
printf("You are incorrect, try again...\n");
scanf("%d", &b);
}
if(b == a)
{
printf("You win! The correct number is %d, enter to exit...\n", a);
getchar();
return 0;
}
getchar();
return 0;
}