How to execute gcc installation on Ubuntu?
To install GCC and run it on Ubuntu, follow these steps:
- Open the terminal by pressing the Ctrl+Alt+T keyboard combination, or by finding it in the applications menu.
- Install GCC: Enter the following command in the terminal and press Enter to install GCC.
- Update using sudo apt and install gcc.
- Enter the password and confirm the installation.
- 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:
- Include the standard input/output library, then define a main function that prints “Hello, World!” and returns 0.
- Save the file: store the file at your chosen location, such as on the desktop.
- Compiler: enter the following command in the terminal and press Enter to compile the C program.
- Compile the hello.c file using gcc and output the executable as hello.
- This will create an executable file named hello.
- Run the program: Enter the following command in the terminal and press the Enter key to run the program.
- Can you please run the “hello” script?
- The output should be Hello, World!
Now, you have successfully installed GCC and run a simple C program.