How to execute gcc installation on Ubuntu?

To install GCC and run it on Ubuntu, follow these steps:

  1. Open the terminal by pressing the Ctrl+Alt+T keyboard combination, or by finding it in the applications menu.
  2. Install GCC: Enter the following command in the terminal and press Enter to install GCC.
  3. Update using sudo apt and install gcc.
  4. Enter the password and confirm the installation.
  5. Write a C program: Using any text editor (such as gedit, nano, etc.) create a simple C program. For example, create a file named hello.c with the following content:
  6. Include the standard input/output library, then define a main function that prints “Hello, World!” and returns 0.
  7. Save the file: store the file at your chosen location, such as on the desktop.
  8. Compiler: enter the following command in the terminal and press Enter to compile the C program.
  9. Compile the hello.c file using gcc and output the executable as hello.
  10. This will create an executable file named hello.
  11. Run the program: Enter the following command in the terminal and press the Enter key to run the program.
  12. Can you please run the “hello” script?
  13. The output should be Hello, World!

Now, you have successfully installed GCC and run a simple C program.

bannerAds