Skip to content

Latest commit

 

History

History
43 lines (32 loc) · 653 Bytes

File metadata and controls

43 lines (32 loc) · 653 Bytes

Hello World first C Program

Create a new file named d.c.

/*
multi line comment usually at top of file.
*/

#include <stdio.h>  // import statement for use of  printf function

// is a single line comment

int main(void) // main function
{
    // main function body inside {}
    printf("Hello World\n"); // pass argument string "Hello World\n" to printf function
    printf("Line 2!\n"); // \n = newline character
    printf("Line 3!\n");
    return 0;
}

Compile file d.c to create new file d

Open terminal and type:

$ gcc -o d d.c

Execute file d.

$ ./d

Expected output

$ ./d
Hello World
$