Day 1 with C
Letter C

Day 1 with C

The first program every programmer writes in a new programming language is to print Hello, World! Let us do that in C.

#include <stdio.h>  //include information about the standard library

int main() // define a function named main tat receives no arguement values
{
   // statements of main are enclosed in braces

   printf("Hello, Wordl!\n");
   
//    main calls a library function printf to print the sequences of    //    characters. \n represents the newline character.
//
}        

Just how you run the program depends on the operating system you are using. On Linux-based OSes, you can use gcc to compile the program. Suppose the code is stored in a file called helloworld.c; you can compile it by using the command below.

gcc helloworld.c -o hello
./hello

// -o mean the output should be stored in a filed called hello which we then run.
// the result of the code will be the words "Hello, Wordl!" being printed on the standard output.        

要查看或添加评论,请登录

Daniel Byiringiro的更多文章

社区洞察

其他会员也浏览了