I assume that the random number is the same value everytime you run the program.
You are not seeding the random number generator properly, I tried this and it seems OK.
# include<stdio.h>
# include<stdlib.h>
# include<time.h>
int main() {
int number;
int guess = 0;
int nguesses = 1;
time_t t;
srand((unsigned) time(&t));
number = rand() % 100;
printf("The number is %d\n", number);
do {
printf("Guess the number between 1 to 100\n");
scanf("%d", guess);
if (guess < number) {
printf("Higher number please!\n");
}
else if (guess > number) {
printf("Lower number please!\n");
}
else {
printf("You guessed it in %d attempts\n", nguesses);
}
nguesses++;
} while (guess != number);
return 0;
}