Prog#091: No.of Lines in a Text

/* 
Program#91
No.of Lines in a Text
*/

#include <stdio.h>
main(){
char a[100];
int i,l;
i=0;

scanf("%c",&a[i]);
while(a[i]!='$'){
i++;
scanf("%c",&a[i]);
}
a[i]='\0';

i=0;l=0;
while(a[i]!='\0'){
if(a[i]=='\n')
l++;
i++;
}
printf("\n l=%d",l);
}