Timer is Running

Comment Removal
Submissions: 1062   Accuracy:


  Difficulty: Easy   Marks: 2

Given a piece of code, the task is to remove all the comments from the code. The code is given in a single line. Newline characters are used only to end the single line comments starting with //

Comments formats can be " /*...*/ " and " //... \n".

Comments cannot be nested.

Input: The first line of the input contains an integer T, denoting the number of test cases. Then T test cases follow. Each test case consists of a single line containing a piece of code which may or may not have comments.

Output: Corresponding to each test case, output a single line contaning the code without comments.

Note: Single line comments should be removed including the newline character in the end.

Constraints: 4 < |code| < 100000


#include int main(int *argc,char **argv){ // First line of code\n printf("Hello World!!! "); return 0; }
#include int main(int *argc,char **argv){ /* First line of code Printing Hello World */ printf("Hello World!!! "); return 0; }

#include int main(int *argc,char **argv){  printf("Hello World!!! "); return 0; }
#include int main(int *argc,char **argv){  printf("Hello World!!! "); return 0; }

** For More Input/Output Examples Use 'Expected Output' option **

Author: Mukesh Kumar 5

If you have purchased any course from GeeksforGeeks then please ask your doubt on course discussion forum. You will get quick replies from GFG Moderators there.

Need help with your code? Please use ide.geeksforgeeks.org, generate link and share the link here.

to report an issue on this page.