You are receiving a continuous stream of numbers, at any point i'll provide a range eg: 5- 15 and the output should be the number of numbers between 5-15.
P.S. - Since the input is a stream the output can change for the same range if the function is called again.
P.S. - Since the input is a stream the output can change for the same range if the function is called again.
The code can be handled using standard file handling of C. The following code should help:
ReplyDelete/* Assuming that the stream is already open */
void DisplayNum(FILE* stream, int min, int max)
{
int no;
while(stream != null)
{
no = fgetc(stream);
if(no>=min && no<=max) printf("%d",no);
}
}