#include <stdio.h>
#include <stdlib.h>
int main()
{
int num=0,ch='9';
while((ch=getchar())!=EOF){
++num;
}
printf("\n%d",num);
}
/* this is a program to count no of characters entered using getchar().
suppose i entered
1
2
3
4
5
answer displayed is 10 not 5

The function
getcharreads any character including white space characters as for example the new line character'\n'that corresponds to the pressed key Enter as demonstrated by the output of your programIf you want to skip white space characters you can write for example
If you want to skip only new line characters then the program can look the following way
An alternative approach is to use another standard function
scanfas for examplePay attention to the leading space in the format specification
It allows to skip white space characters.