Sunday 3 December 2017

C Program to count number of lines and exit when user type '~'

#include<stdio.h>

void main(){

int lineCount,temp;
while((temp=getchar())!=EOF){

if(temp=='\n')
++lineCount;
if(temp=='~')
break;
}

printf("%d",lineCount);

}

No comments:

Post a Comment