Explanation
The following code is written in C programming language, and it is a simple program that outputs "Hello World" on the console.
#include <stdio.h>
The first line includes the header file stdio.h
, which stands for Standard Input/Output.
This header
file provides various functions that allow a program to input and output data, such as reading from
the keyboard and
writing to the console.
int main()
The main
function is the entry point of the program, where execution starts. The
int
keyword before the main
function indicates that the function will return an integer
value.
printf("Hello World \n");
The printf
function is defined in the stdio.h
header file and is used to
print a message to
the console. The argument passed to the printf
function is a string of characters that
represent the
message to be printed. The string "Hello World \n" will be printed on the screen, and the
\n
at the end
represents a newline character, which causes the cursor to move to the next line after the message
is printed.
return 0;
The return 0;
statement at the end of the main
function indicates that the
program executed
successfully and returns an exit code of 0 to the operating system.
Other functions available in the stdio.h
header file:
scanf
: Used for reading formatted input from the keyboard.fprintf
: Used for printing to a file instead of the console.gets
: Used for reading a string from the keyboard.
These are just a few of the functions available in the stdio.h
header file. There are
many other
functions available for input/output operations in C.
Code
/*
* -----------------------------------------------------------
* Logic Building with Computer Programming (CSU1128)
* Instructor: Dr. Pankaj Vaidya | Author: Divya Mohan
*
* This code is a part of the educational initiative by dmj.one
* with aim of empowering and inspiring learners in the field of
* Computer Science and Engineering through the respective courses.
*
* (c) 2022, Divya Mohan for dmj.one. All rights reserved.
* -----------------------------------------------------------
*/
#include <stdio.h>
int main()
{
printf("Hello World \n");
return 0;
}
Output
Hello World