The classic “Hello World” program in the c language 

C Language

 In this section, we will learn how to write a simple C program. Let us know what hello world is in the c program; the line hello world program tells the compiler to display the statement “hello world “on screen.

How does the hello world program work?

Hello world program in c language

#include<stdio.h>

int main ()

{

Printf (“Hello world!”);

Return 0;

}

Now let us see how the program works.

The #include is a preprocessor command, and it tells the compiler to include the contents of stdio.h, that the is standard input and output file in the program and has functions such as printf () and scanf () to take input and output the display on the screen. Printf (), scanf () functions without writing #include<stdio.h> will not compile .printf is library function to send output on screen.

The execution of the program starts from the main () function.

The int written before the main () function is a return type of the main () function.

The curly braces { } just before the main function enclose the body of the main () function.

Return 0; statement is the exit status of the program; the program will end with this statement.

It is important to note that every statement in a C should end with a semicolon (;) if we miss adding any semicolon, it will be a compiler error.

How to write a C program on my computer?

All the C programs can be written and edited in text editors such as notepad, and they must be saved with a file name and with a .c extension.

Example: HelloWorld.c

Here HelloWorld is the file name.

If we not add .c extension, the compiler will not recognize it is a c program.

The different preprocessors in c programming language are

#include

#if

#define

#ifdef

#undef

Let us see how the comments can be added to a c program

To add single-line comments, we can use slash// followed by the comments

//*comments here*//

What is the stdio. h program in c language?

The studio stands for standard input and output and .h extensions of the file, including the header file.

The main use of this header file is that it helps to get the input from the keyboard and return the output on the screen.

Scanf () takes the input, and printf () prints the output on the screen.

Leave a Reply

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