Program 2
Program 2
2.1 PROGRAM:
#include<stdio.h> #include<conio.h> void main() {
char com[30]; int i=2,a=0; clrscr();
printf("\n Enter comment:"); gets(com);
if(com[0]=='/') {
if(com[1]=='/')
printf("\n It is a comment"); else if(com[1]=='*') {
for(i=2;i<=30;i++)
{
if(com[i]=='*'&&com[i+1]=='/')
{
printf("\n It is a comment"); a=1;
break; }
} else continue; }
else if(a==0)
printf("\n It is not a comment");
printf("\n It is not a comment");
}
else
printf("\n It is not a comment"); getch(); }
2.2 INPUT & OUTPUT:
Input: Enter comment: //hello
Output: It is a comment
Input: Enter comment: hello
Output: It is not a comment
// C Program to count
#include <stdio.h>
int main()
FILE* fp;
int count = 0;
char filename[MAX_FILE_NAME];
char c;
fp = fopen(filename, "r");
if (fp == NULL) {
filename);
return 0;
count = count + 1;
fclose(fp);
filename, count);
return 0;