/* Latihan. 2.1: lat02_01.c A first program in C */ #include <stdio.h> int main() { printf( "Welcome to C!\n" ); return 0; } |
Welcome to C! |
- Comments
- #include <stdio.h>
- int main()
- printf( "Welcome to C!\n" );
- return 0;
- Right brace }
- Linker
- Text surrounded by /* and */ is ignored by computer
- Used to describe program
- Preprocessor directive
* Tells computer to load contents of a certain file
- <stdio.h> allows standard input/output operations
- C++ programs contain one or more functions, exactly one of which must be main
- Parenthesis used to indicate a function
- int means that main "returns" an integer value
- Braces ( { and } ) indicate a block
* The bodies of all functions must be contained in braces
- Instructs computer to perform an action
* Specifically, prints the string of characters within quotes (" ")
- Entire line called a statement
* All statements must end with a semicolon (;)
- Escape character (\)
* Indicates that printf should do something out of the ordinary
* \n is the newline character
- A way to exit a function
- return 0, in this case, means that the program terminated normally
- Indicates end of main has been reached
- When a function is called, linker locates it in the library
- Inserts it into object program
- If function name is misspelled, the linker will produce an error because it will not be able to find function in the library
No comments:
Post a Comment