///C program that can check a given line is comment or not
/*
Alamgir Hossain
Computer Science & Engineering
Jessore University of Science & Technology
*/
#include<stdio.h>
int main()
{
char ch[1000];
int ck = 0,i,ln;
printf("Enter the line : ");
gets(ch);
ln = strlen(ch);
if(ch[0]=='/'){
if(ch[1]=='/'){
printf("Its a comment line\n");
}
else if(ch[1]=='*'){
for(i=2;i<ln;i++){
if(ch[i]=='*'&&ch[i+1]=='/'){
printf("Its a comment line\n");
break;
}
else{
ck = 1;
}
}
}
}
else if(ck==1){
printf("Its not a comment.\n");
}
else{
printf("Not a Comment line\n\n");
}
return 0;
}
/*
Alamgir Hossain
Computer Science & Engineering
Jessore University of Science & Technology
*/
#include<stdio.h>
int main()
{
char ch[1000];
int ck = 0,i,ln;
printf("Enter the line : ");
gets(ch);
ln = strlen(ch);
if(ch[0]=='/'){
if(ch[1]=='/'){
printf("Its a comment line\n");
}
else if(ch[1]=='*'){
for(i=2;i<ln;i++){
if(ch[i]=='*'&&ch[i+1]=='/'){
printf("Its a comment line\n");
break;
}
else{
ck = 1;
}
}
}
}
else if(ck==1){
printf("Its not a comment.\n");
}
else{
printf("Not a Comment line\n\n");
}
return 0;
}
No comments:
Post a Comment