Coding-Problem Solving

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);

}

Posted by Shivam at 09:09 No comments:
Email ThisBlogThis!Share to XShare to FacebookShare to Pinterest
Newer Posts Older Posts Home
Subscribe to: Posts (Atom)

About Me

Shivam
View my complete profile

Blog Archive

  • ►  2018 (18)
    • ►  March (2)
    • ►  February (3)
    • ►  January (13)
  • ▼  2017 (2)
    • ▼  December (1)
      • C Program to count number of lines and exit when u...
    • ►  September (1)
Awesome Inc. theme. Powered by Blogger.