There are some steps to write the First Program in C Language
1. Install a C Compiler
Before you start writing C programs, you need to install a C compiler. If you did not install then please check my last article for How to install C Compiler on your machine.
2. Create Your First Program
Once you have the compiler installed, you can create your first program. Let’s write a basic “Hello, removeload.com!” program.
Example:
#include <stdio.h> // Preprocessor directive to include standard input/output header file
int main() {
printf("Hello, removeload.com!"); // Prints "Hello, removeload.com!" to the console
return 0; // Exit the program successfully
}
Explanation of the Code:
#include<stdio.h>: This tells the compiler to include the standard input/output library that allows us to use functions like printf.
int main(): This is the entry point of every C program. The program starts executing here.
printf(“Hello, removeload.com!”);: This line prints the message Hello, removeload.com! to the screen.
return 0;: This indicates that the program has successfully completed and returns control to the operating system.
3. Save and Compile the Program
1. Save the program in a file with the .c extension, for example, hello.c.
2. Now, open a terminal/command prompt and navigate to the directory where your program is saved.
3. To compile the program, use the following command (assuming you’re using GCC).
gcc hello.c -o hello
This will create an executable file called hello (or hello.exe on Windows).
4. Run the Program
After compilation, you can run your program:
On Linux/macOS:
./hello
On Windows:
hello
Output: