Let’s start with a little coding, which will really make you a computer programmer. We are going to write a single-line computer program to write Hello, World! on your screen. Let’s see how it can be written using different programming languages.
Hello World Program in C
Try the following example using our online compiler option available at www.compileonline.com.
For most of the examples given in this tutorial, you will find a Try it option in our website code sections at the top right corner that will take you to the online compiler.
Try to change the content inside printf(), i.e., type anything in place of Hello World! and then check its result. It just prints whatever you keep inside the two double quotes.
#include <stdio.h> int main() { /* printf() function to write Hello, World! */ printf( "Hello, World!" ); }
which produces the following result −
Hello, World!
This little Hello World program will help us understand various basic concepts related to C Programming.
Program Entry Point
For now, just forget about the #include <stdio.h> statement, but keep a note that you have to put this statement at the top of a C program.
Every C program starts with main(), which is called the main function, and then it is followed by a left curly brace. The rest of the program instruction is written in between and finally a right curly brace ends the program.
The coding part inside these two curly braces is called the program body. The left curly brace can be in the same line as main(){ or in the next line like it has been mentioned in the above program.
Functions
Functions are small units of programs and they are used to carry out a specific task. For example, the above program makes use of two functions: main() and printf(). Here, the function main() provides the entry point for the program execution and the other function printf() is being used to print an information on the computer screen.
You can write your own functions which we will see in a separate chapter, but C programming itself provides various built-in functions like main(), printf(), etc., which we can use in our programs based on our requirement.
Some of the programming languages use the word sub-routine instead of function, but their functionality is more or less the same.
Comments
A C program can have statements enclosed inside /*.....*/. Such statements are called comments and these comments are used to make the programs user friendly and easy to understand. The good thing about comments is that they are completely ignored by compilers and interpreters. So you can use whatever language you want to write your comments.
Research Resources: Internet -- I am not owner of any thing!

Post a Comment