0
    n=10;
    for(i=1;i<n;i++){
        random = 1 + rand() % 3;  
        printf("\n\nIzdari savu izveli ==>");
        scanf("%c", &zime);
        if( zime=='a' )
            printf("\nTu uzliki AKMENI");
        else if( zime=='s' )
            printf("\nTu uzliki SKERES");
         else if( zime=='p' )
            printf("\nTu uzliki PAPIRU");

        if( random==1 )
            printf("\nDators uzlika AKMENI");
        else if( random==2 )
            printf("\nDators uzlika SKERES");
        else if( random==3 )
            printf("\nDators uzlika PAPIRU");

        if( random==1&&zime=='a' || random==2 && zime=='s' || random==3 && zime=='p')
        printf("\n\nNeizskirts!!!");
    else if( random==1&&zime=='p' || random==2&&zime=='a' || random==3&&zime=='s' )
        printf("\n\nTu Uzvareji!!!");
    else if( random==1&&zime=='s' || random==2&&zime=='p' || random==3&&zime=='a' )
        printf("\n\nTu Zaudeji!!!");
    getch();
    }

Why when loop starts 2nd time it just skips scanf, and jumps to if( random==1 ), and then jumps back to scanf and let u scanf a char?

Output looks like

a

It is just rock paper scizors game, but in other language.

slavoo
  • 5,798
  • 64
  • 37
  • 39

1 Answers1

1

There is a newline character \n at the end of first input and that is picked by the scanf() during the second loop.

Chnage your scanf as :

scanf(" %c", &zime);
Gopi
  • 19,784
  • 4
  • 24
  • 36