fork download
  1. #include<stdio.h>
  2. #include<string.h>
  3.  
  4. int main()
  5. {
  6. char line[100];
  7. int len;
  8.  
  9. // printf("enter a line: ");
  10. gets(line);
  11.  
  12. len = strlen(line);
  13.  
  14. // check single line comment
  15. if(line[0]=='/' && line[1]=='/')
  16. {
  17. printf("it is a comment\n");
  18. }
  19. // for multi line comment
  20. else if(line[0]=='/' && line[1]=='*')
  21. {
  22. if(line[len-1]=='/' && line[len-2]=='*')
  23. {
  24. printf("it is a comment\n");
  25. }
  26. else
  27. {
  28. printf("not a valid comment\n");
  29. }
  30. }
  31. else
  32. {
  33. printf("it is not a comment\n");
  34. }
  35.  
  36. return 0;
  37. }
Success #stdin #stdout 0.01s 5324KB
stdin
Hello World
stdout
it is not a comment