Program to count the number of statement terminators and opening braces
Program to read a C program and count the number of statement terminators and the number of opening braces.
#include<stdio.h> main() { FILE *fp; int s=0,b=0; char c; fp=fopen(“fib.c”,”r”); while((c=getc(fp))!=EOF) { if(c==’;’) s++; if(c==’{‘) b++; } fclose(fp); printf(“\t\n number of statement terminators=%d”,s); printf(“\t\n no of opening braces=%d”,b); }
Output:
Share: