First C Program


#include <stdio.h>
int main(void){
    printf("Hello World!\n");
    return 0;
}


#include <stdio.h>

  • The statement suggests that including the #include <stdio.h> directive at the beginning of almost every program is essential. 
  • This directive informs the compiler to include the standard input-output header file, stdio.h, as part of the program. 
  • The stdio.h file contains information about the printf output routine, which is commonly used later in the program.

int main(void)

  • The declaration of the `main` function plays a crucial role in a C program, as it communicates vital information to the system about the program's structure and execution flow. 
  • By specifying the name of the program as `main` and indicating its return type as "int," denoted for integer values, developers convey essential details to the compiler. 
  • The term "main" serves as more than just a label; it is a special name that precisely designates the starting point of program execution. 
  • The parentheses immediately following `main` signify its nature as a function. Furthermore, the inclusion of the keyword `void` within these parentheses conveys that the `main` function does not take any arguments, highlighting its simplicity in terms of input parameters. 
  • This concise declaration encapsulates key details about the program's entry point, return type, and argument structure, contributing to the clarity and functionality of C programs.

{}

  • Describe the boundary of the main function.
  • This is done by enclosing all program statements of the routine within a pair of curly braces.

return 0;

In C programming, return 0; is a statement used within the main function to indicate the successful completion of a program. The return statement is used to send a value back to the operating system, and the value 0 is often used conventionally to signify that the program has executed without encountering errors.
  1. Exit Status
  2. Success Convention
  3. Error Handling
Including return 0; at the end of the main function is not strictly necessary in modern C. If you omit it, the compiler will implicitly assume return 0; at the end of main. However, it's a good practice to include it explicitly for clarity, especially in larger programs or when working on platforms where the convention might differ.

printf("Programming is Fun\n");

\n

  • Any characters to be printed after the newline character then appear on the next line of the display. 


πŸ‘‰All program statements in C must be terminated by a semicolon (;).πŸ‘ˆ

Comments

Popular posts from this blog

Tutorial 11 & 12

Format Modifiers (Format Specifiers)

Simple and basic C program code