Tuesday, March 11, 2014

Hello World: C

Problem Question


Write the Hello World Program in C Language

Explanation of Problem


Hello World Program, is the first program generally taught when you take some programming classes. This program is one of the simplest program to write and perhaps every coder has written this once in their life. This program helps in checking that the compiler is working fine as far as the basic functionality is concerned.

Code




/*Hello World program
*Language: ANSI C
*Compiler: GNU GCC
*IDE: CodeBlocks 12.11
*Written by: Toxifier
*URL: http://letsplaycoding.blogspot.com/
*Date: 11-03-2014*/

#include <stdio.h>

int main()
{
printf("Hello World, from Toxifier");
return 0;
}


Explanation of Code


#include <stdio.h> -> This statement calls the C preprocessor to include the Header File named STDIO(Standard Input/Output). Thus, all the functions declared in this header file(and defined in it's linked file) are available for your use in the program.

int main() -> The starting point of program execution is the main function. In ANSI C, main needs to be returning an integer value, that's why the return type is int

printf("Hello World, from Toxifier") -> This statement calls the printf function from stdio and which prints the string that is passed to it.

return 0 -> A zero returned implies no problem during execution. In ANSI C main returns an int, which is preferably zero. We use non-zero values to indicate an error. The values help in debugging.

{} -> These braces are block delimiters. The statements inside a pair of braces become the part of a block which is sequentially executed.

Output(s)




No comments:

Post a Comment

Need help?