Skip to content

How to code and execute C++ in colab.research.google.com?

Notifications You must be signed in to change notification settings

harithiduwara/CppIncolab

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

11 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

How to code C++/C in https://colab.research.google.com ?

Step 1: Write %%writefile FILENAME.cpp in the first line of the code block

%writefile FILENAME.cpp

OR

%writefile FILENAME.c

example:

%%writefile constructors.cpp

#include <iostream>

using namespace std;

int main(){

	cout<<"Hello!"<<endl;

	return 0;

}

Step 2: Code whatever you want in CPP in that block after the %%writefile FILENAME.cpp line and run the block.

Step 3: Check whether the file is created or not by writing and executing the below code segment in a code block

!ls -l

There will be a file called FILENAME.cpp

Step 4: Now you can execute FILENAME.cpp by writing and executing the below code segment

%%shell

g++ FILENAME.cpp -o output

./output

OR

%%shell

g++ FILENAME.c -o output

./output

About

How to code and execute C++ in colab.research.google.com?

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published