run c++ files on chrome book

You can run C++ files on a Chromebook by following these steps:

  1. Install Linux (Beta):
  2. Open "Settings" on your Chromebook.
  3. Go to "Advanced" and then "Developers".
  4. Enable the "Linux (Beta)" option and follow the on-screen instructions to install it.

  5. Open Terminal:

  6. Once Linux is installed, open the Terminal either by searching for it or using the keyboard shortcut Ctrl + Alt + T.

  7. Update APT (Advanced Package Tool):

  8. Type sudo apt-get update and press Enter.
  9. Enter your password if prompted, then wait for the update to complete.

  10. Install g++ Compiler:

  11. Type sudo apt-get install g++ and press Enter.
  12. Confirm the installation by typing Y and then press Enter.

  13. Write C++ Code:

  14. Use a text editor like Nano or Vim to write your C++ code. For example, type nano hello.cpp to create a new file named hello.cpp.

  15. Write Your Code:

  16. Enter your C++ code in the editor. For instance, a simple "Hello, World!" program: ```cpp #include using namespace std;

    int main() { cout << "Hello, World!" << endl; return 0; } ```

  17. Save and Exit:

  18. Press Ctrl + X to exit Nano or Vim.
  19. Confirm to save changes by typing Y and then press Enter.

  20. Compile Your Code:

  21. In the Terminal, type g++ hello.cpp -o hello and press Enter. This compiles your hello.cpp file and creates an executable named hello.

  22. Run the Program:

  23. Type ./hello and press Enter to execute the compiled program. You should see the output printed in the Terminal.

These steps will allow you to write, compile, and run C++ programs on your Chromebook using the Linux environment.