Within your while loop the variable guess
is not being changed
while(guess != num){
printf("%d", guess);
++turns;
printf("Turns:\n");
printf("%d", turns);
guess;
}
Moreover this line
guess;
does not have an effect.
And this statement before the while loop
guess = getchar();
does not make a sense because the function getchar
reads only one character and returns the value of the internal representation of the character.
Also pay attention to that according to the C Standard the function main without parameters shall be declared like
int main( void )
Your program can look the following way
#include <stdio.h>
int main( void )
{
unsigned int num = 13;
unsigned int turns = 0;
unsigned int guess = 0;
puts( "Try to guess the number I thought." );
printf( "Enter a non-negative number: " );
while( scanf( "%u", &guess ) == 1 && guess != num )
{
printf( "%u is not my number.\n", guess );
++turns;
printf( "It is your %u attempt\n", turns );
printf( "\nEnter a non-negative number: " );
}
if ( guess == num )
{
printf( "\nYou have guessed the number using %u guesses.\n", turns );
}
else
{
printf( "\nYou have not guessed the number using &u guesses.\n", turns );
}
}