The "Hello, World!" program is a classic and simple program that is often used to introduce a new programming language. The program simply prints the message "Hello, World!" to the screen. In the C programming language, the "Hello, World!" program is typically written as follows:
If you are using Turbo C++, you need to include conio.h
header file and call clrscr();
function at beginning and getch();
function at end.
#include <stdio.h>
#include <conio.h>
void main(){
clrscr();
printf("Hello World");
getch();
}
#include <stdio.h>
void main(){
printf("Hello World");
}
Hello World
#include <stdio.h>
, is a preprocessor directive that tells the compiler to include the contents of the standard input/output header file (stdio.h) in the program. This header file contains declarations for the standard input/output functions, such as printf().int main()
line defines the main function of the program. This is the entry point of the program, and the code within the curly braces ({}
) will be executed when the program runs.printf("Hello, World!\n");
, calls the printf()
function to print the string "Hello, World!" to the standard output (usually the console). The \n
at the end of the string is called a newline character, which causes the cursor to move to the next line after the string is printed.return 0;
, is a return statement that tells the operating system that the program has finished executing successfully.Learning C programming can seem daunting at first, but starting with a simple program like "Hello, World!" can help you to understand the basics of the language and build a solid foundation for more advanced programming. So, dive in and start experimenting with the language. Happy coding!