Hello World Program in C
Tags: programming, tutorial, beginners, cprogramming
Published: 2021-02-10 07:21:18

<p>In this tutorial, we will see how to write a <a href="https://usemynotes.com/hello-world-program-in-c/">hello world program in c</a>, how to write the comments in c program, and what header files are. so let us start.</p>
<h2>How can we write a hello world program in c?</h2>
<p>To write a program in c we first have to declare the header file. And after that, we have to declare the main function. Inside the main function, we can write the code that we want to execute.</p>
<div class="table-responsive">
<table class="table table-bordered table-striped">
<tbody>
<tr>
<td>
<p>/* Header file declaration */<br>
#include&lt;stdio.h&gt;</p>
<p>/* Main function declaration */<br>
int main() {</p>
&nbsp; &nbsp; <p>/* Printing message to screen */<br>
&nbsp; &nbsp; printf("Hello World!");</p>
&nbsp; &nbsp;<p>/* returning */<br>
&nbsp; &nbsp; return 0;<br>
}</p>
</td>
</tr>
</tbody>
</table>
</div>
<p><strong>Output:-</strong></p>
<table class="table table-bordered table-striped">
<tbody>
<tr>
<td><p>Hello World!</p></td>
</tr>
</tbody>
</table>
<p>In the first-line we will include the &lt;stdio.h&gt; header file in the program. The stdio.h stands for standard input/output .header file. It handles the input and output statements of the program.</p>
<p>After this, the main() function is started. In this function instruction of the program is written. In the Main function, the starting point or endpoint is represented by the curly brackets({ }).</p>
<p>In this, the main function is defined by the int type. The main function has to always return an integer value (int). In the program, if we do not return any value from the main() function then we have to write return 0 at the end of the program.</p>
<h2>How to write a comment in the c program?</h2>
<p>A comment is a text that is not compiled by the compiler but it is ignored. This text is not executed. Comments are used in the C program to define any statement. A comment is the explanation of the source code of the program.  The comments are not executed and are not shown in the executed code.</p>
<p>There are two types of comments- end-of-line comment and block comment. The end-of-line comment terminates at the end of the line. A block line comment contains a terminator and can continue for several lines.</p>
<table class="table table-bordered table-striped">
  <tbody>
    <tr>
      <td>/* This is my first program */</td>
    </tr>
  </tbody>
</table>
<p>In the C language to define the comments, we use forward-slash (/) along with the asterisk sign (*). It is mainly used by the coder in the longer codes to remind him which part of the code is for what. So that the modification in the code can be done easily. It can also be used as a helper for those who will read the code later. They will be able to understand the code more easily and can change the code according to the requirement.</p>
<h2>What is a header file?</h2>
<p>The header file is a file that contains function declarations and macro functions. The header file is used for defining all the functions, variables, and constants. When a header file is included in the program by using #include&lt;filename.h>command all the headers are included in the program. The c program is compiled with the help of the compiler and executed. The header file stdio.h includes two standard input-output functions scanf and printf. They contain the function prototype.</p>