c Program to Count Number of Lines in Input until Interrupted by CTRL + Z


Program to Count Number of Lines in Input until Interrupted by CTRL + Z
Program
#include<stdio.h>
void main()
{
int no_lines = 0;
char ch;
printf("\nPlease Enter the Data...\n");
while((ch = getchar()) != EOF)
if(ch == '\n')
++no_lines;
printf("\nThe Number of Lines Entered are : %d\n", no_lines);
}

No comments: