First C Program

first c program

First C Program – C is a general-purpose, procedural programming language that has been widely used since its development in the early 1970s. Writing a simple “Hello, World!” program is a great way to get start with C.

Here are the steps you can follow to write your first C program:
  1.  Open a text editor: To write your C program, you’ll need a text editor.  You can use any text editor of your choice, such as Notepad, Sublime Text, or Visual Studio Code.
  2. Write the program :in your text editor, start by typing the following code:
#include <stdio.h>          
int main()                  
printf(“Hello, World!”);
  return 0;                 
This is a simple program that prints the text “Hello, World!” to the console. The ‘#include <stdio.h>‘ line is needed to use the ‘printf‘ function, which is used to print text to the console.
  • Save the file: Save the file with a “.c” extension. For example, you could name the file “hello.c“.
  • Compile the program: To compile your program, you’ll need a C compiler. The most popular C compiler is GCC, which you can download for free. Once you have GCC installed, open a terminal or command prompt and navigate to the directory where your “hello.c” file is saved. Then type the following command:
gcc -o hello hello.c
This command tells GCC to compile the “hello.c” file and create an executable file called “hello“. The “-o” option specifies the output file name.
  •   Run the program: Once the program is compiled, you can run it by typing the following command in the terminal or command prompt:
This will run the “hello” executable and print “Hello, World!” to the  console.
Congratulations, you’ve written and run your first C program!

Table of Contents

GCC Information

  • GCC (GNU Compiler Collection) is a popular open-source compiler used to compile C, C++, and other programming languages. It is widely used in the development of software and operating systems. GCC is available on many different platforms, including Linux, macOS, and Windows.
  • GCC supports several optimization levels, which can improve the performance of the generated code. The optimization levels range from -O0, which turns off all optimizations, to -O3, which performs aggressive optimizations. However, it’s important to note that aggressive optimization levels may result in longer compile times and more complex code.
  • GCC also supports a variety of extensions to the C language, such as inline assembly and various language features that are not part of the C standard. These extensions can be useful in specific situations but may not be portable across different compilers.
  • In addition to compiling code, GCC also provides a suite of debugging tools, such as GDB, which is a popular debugger used to debug programs on Linux and other Unix-based systems.
  • GCC is free and open-source software, which means that anyone can use, modify, and distribute it under the terms of the GNU General Public License (GPL). This has led to the widespread use and development of GCC, with contributions from individuals and organizations around the world.

C compiler

A C compiler is a software tool that translates C source code into machine code that can be executed by a computer. C compilers are used to develop a wide range of software, from small programs to large systems and operating systems.
There are many C compilers available, both free and commercial, for various platforms and operating systems. Some of the most popular C compilers are:
  • GCC (GNU Compiler Collection): GCC is a free, open-source compiler that supports multiple programming languages, including C. It is widely used on Linux and other Unix-based systems.
  • Clang: Clang is a free, open-source C compiler developed by Apple. It is designed to be compatible with GCC and supports many of its extensions.
  • Microsoft Visual C++: Microsoft Visual C++ is a commercial C compiler for Windows. It is commonly used for developing Windows applications and has good integration with Microsoft Visual Studio.
  • Turbo C++: Turbo C++ is a popular C compiler for Windows, especially for beginners. It has a simple and easy-to-use interface and is often used for learning C programming.
  • Borland C++: Borland C++ is another popular C compiler for Windows. It supports both C and C++ programming and has a rich set of features and tools.
Also Read: Features of C Language | Programming

1 thought on “First C Program”

Leave a Comment