I tried writing a C program to say the number of times you guessed the right number.
#include <stdio.h> #include <stdlib.h> int main() { int i, searchNumber, Number, rightGuess; rightGuess = 0; printf("Give your number: "); scanf("%d",&searchNumber); printf("\n\n Give 10 numbers: "); for(i=1;i<=9;i++){ scanf("%d \n",&Number); if(Number == searchNumber){ rightGuess++; } } printf("You guessed the number %d times",&rightGuess); return 0; }
However, every time I run it, it says that I guessed number 6356736 times. Although I only entered the number 0 times. Any help?
source share