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

How to write a C Program to Count Number of Lines in Input until Interrupted by CTRL + Z in C Programming Language ?

Solution For C Program :

/*C Program to Count Number of Lines in Input until Interrupted by CTRL + Z*/
#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);
}

You may also learn these C Program/Code :

C Program To Swap Two Numbers Without Using Third Variable


Learn More :