my-first-c-program-hello-worldThis our first C program. This is the most basic program which prints a simple text only.

Now in this article not only we are going to show you the code of the program and its output but also we are going to discuss the meaning of each and every line.

Code

OUTPUT


Code Explanation

  • # : In C programming, # represents preprocessor directives. It simply tells the compiler that before compiling the program, first process the statement that starts with a #. Hence the name PRE Processor.
  • include : This tells the compiler to include something.
  • < what to include >
  • stdio : The ‘stdio‘ stands for Standard Input / Output. So why we are using it? Because we want an output from this program. The text which we are displaying on the screen.
  • stdio.h :   h‘ stands for ‘header‘. The stdio is a header file which consists of many predefined functions. It makes a programmer’s job easier. How? You can also print something without using stdio header file. But its a complicated task and time consuming. So we use this header file in C programming.
  • int main() : The ‘main()‘ is the starting point of a program. A program needs to be started from somewhere. In C the ‘main()‘ is a user implemented function. Here by user implemented function I mean that the prototype of this ‘main()‘ function is predefined  by the C compiler.And the reason we used int is that the main() function returns an integer type variable. So at the end of the program, we are returning the integer variable 0. The main function always returns a value. So we also need the return statement when using ‘int main‘.
  • printf() : We use printf() function to display something on the output screen. The printf() is the library function in C which is built in the header file stdio.h.
  • (” your text “) : Everything inside the double quotation is printed on the screen.
  • ; this is the statement terminator. Every statement in C must end with a ‘;‘ indicating the termination of a statement.
Hello World – My first C Program
Tagged on:

Leave a Reply

Your email address will not be published. Required fields are marked *