Write a C program to identify whether a given line is a comment or not ?

// write a C program to identify whether a given line is a comment or not ?

 

#include<stdio.h>
void main()
{
char com [30];
int i=2,a=0;

printf("\n Enter Text : ");

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;
}
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.");

}

 OUTPUT


इन्हे भी पढ़िए !

  1. What is Variable in Hindi
  2. Keywords & Identifiers in C in Hindi
  3. Comments , Format Specifier & Escape Sequence in C in Hindi 
  4. Dynamic Memory allocation in Hindi 
  5. Math function in Hindi
  6. File Handling in Hindi
  7. how to include graphics.h in Code Blocks(error header file graphics.h)?