Windows Installation

Lesson 2
Author : Afrixi
Last Updated : November, 2022
C - Programming Language
This course covers the basics of programming in C.

C is a popular programming language that can be installed and used on Windows machines. Here is a more detailed explanation of the steps to install C on Windows for beginners:

  • Download a C compiler: A C compiler is a software program that converts the source code written in C into machine code that can be executed by the computer. There are several C compilers available for Windows, such as GCC, Clang, and Microsoft Visual C++. Beginners can start with the GCC compiler, which is free and widely used. To download GCC, visit the official website of the MinGW project (https://www.mingw-w64.org/doku.php) and download the “MinGW-W64-builds” version that matches your Windows system (32-bit or 64-bit).

  • Install the C compiler: After downloading the C compiler, run the installation file and follow the instructions provided by the compiler to install it on your Windows machine. This typically involves running an installation wizard and accepting the default settings. It is important to note the installation path of the compiler for later use.

  • Set up the environment variables: Once the C compiler is installed, you need to set up the environment variables to ensure that the compiler can be accessed from the command line. To do this, go to the Control Panel by clicking on the Windows Start menu and selecting “Control Panel”. Then select “System and Security”, followed by “System”. Click on “Advanced system settings”, and then click on the “Environment Variables” button. Under System Variables, click on “New” and enter the name of the variable as “Path” and the value as the path to the compiler’s bin folder. For example, if you installed GCC in the default location, you would add “C:\MinGW\bin” to the Path variable.

  • Write a C program: Open a text editor such as Notepad or Notepad++ and write a simple C program, such as the “Hello, World!” program. This program simply displays the text “Hello, World!” on the screen. Here’s an example of the program:

#include <stdio.h>

int main() {
    printf("Hello, World!\n");
    return 0;
}
  • Save the C program: Save the C program with a .c extension, such as “hello.c”. Be sure to save it in a location that you can easily find later.

  • Compile the C program: Open the command prompt by clicking on the Windows Start menu and typing “cmd” in the search box. Then navigate to the folder where the C program is saved using the “cd” command. For example, if your program file is saved in the “Documents” folder, you would enter “cd Documents” at the command prompt. Then, enter the command to compile the program, which typically involves running the compiler with the name of the program file as an argument. For example, if your program file is called “hello.c” and you’re using GCC, you would enter the command “gcc hello.c -o hello.exe” to compile the program and create an executable file. The “-o” flag tells GCC to name the output file “hello.exe”.

  • Run the C program: After compiling the program, you can run it by entering the name of the executable file at the command prompt. For example, if your executable file is called “hello.exe”, you would enter the command “hello.exe” to run the program. The program should display the text “Hello, World!” on the screen.

With these steps, beginners should be able to successfully install and run C on their Windows machine.