Today is the first time I use C and I tried some things like if, getchar(), etc. But now my problem is, that my third printf() in my code prints something it shouldnt. But I dont know where the problem is.
The loop should take the c integer and should add '1' every "loop-through". But when I input '5' the loop prints:
You entered: 54
You entered: 55
You entered: 56
You entered: 57
You entered: 58
You entered: 59
You entered: 60
You entered: 61
You entered: 62
You entered: 63
You entered: 64
You entered: 65
You entered: 66
You entered: 67
But it should print something like this:
You entered: 6
You entered: 7
You entered: 8
You entered: 9
You entered: 10
You entered: 11
You entered: 12
You entered: 13
You entered: 14
You entered: 15
You entered: 16
You entered: 17
You entered: 18
You entered: 19
My Code
#include <stdio.h>
int main()
{
printf("Enter a value!: ");
int c = getchar();
printf("You entered: %c\n", c);
int x = 1;
while(x < 15) {
x++;
c++;
printf("You entered: %d\n", c);
}
return 0;
}