Thursday 31 January 2013

C Programming Language Homepage


http://cprogramminglanguage.net/c-hello-world.aspxC Programming Language Homepage

Getting Started with C

Getting Started with C

In this article, you are going to develop the first program in C. You will learn how the sequence of a C program works.

The C program is a set of functions.  A C program always starts executing in a special function which is known as main function. Here is the simple but famous "Hello World" program that prints a greeting message on screen.
1#include <stdio.h>
2main()
3{
4    printf("Hello World!\n");
5    return 0;
6}
Let's examine the program above in details.
  • First, you see #include directive in the first line. Every directive in C is denoted by a sign (#).  C program uses this directive to load external function library - stdio is c library which provides standard input/output. printf () is a function which is declared in the header file called stdio.h
  • Next, you see the main() function - It is the first entry point of a C program. A C program logic starts from the beginning of main function to the its ending.
  • Finally, you notice that we use printf() function which accepts a string as a parameter. The printf() function is used to print out the message on the screen. The main() function is supposed to return an integer number so we put return 0 statement at the end of the program.
In the following section, we will show you step by step running this program in CodeBlock IDE. If you don't have IDE to run the program, you can install CodeBlocks by following the step-by-step tutorial.
Launch the IDE, and create your first project from File > New > Project...
New Console Project
Choose Console appliction



Choose C language

Enter project name and folder to create project in.


Click Run button you will see the console window display the message "Hello world!"

Congratulation! You've developed the first program in C. Let's go to the next tutorials to explore the power of C programming language, enjoy programming!

 

No comments:

Post a Comment