#include<stdio.h>
#include<string.h>
int main()
{
char com[30];
int i,a=0;
printf("\n Enter comment:");
gets(com);
//cin.getline(st, 100);
if(com[0]=='/')
{
if(com[1]=='/')
printf("\n It is a comment");
else if(com[1]=='*')
{
for(i=2; com[i]!='\0'; i++)
{
if(com[i]=='*'&&com[i+1]=='/')
{
printf("\n It is a comment");
a=1;
break;
}
else
continue;
}
if(a==0)
printf("\n It is not a comment");
}
else
printf("\n It is not a comment");
}
else
printf("\n It is not a comment");
return 0;
}
Sample input:
//Hello C program
Sample output:
It is a comment
Tags:
C