Documenti di Didattica
Documenti di Professioni
Documenti di Cultura
Hello World in C
#include <stdio.h> void main() { clrscr();
Comments
Instructions, documentation, description about the program that do not execute Single line comments Multiline comments : : // /*. ..*/
Preprocessor Directives
The #include is a "preprocessor" directive that tells the compiler to put code from the header file called stdio.h into our program before actually creating the executable.
#include<stdio.h> it tells the compiler to include the <stdio.h> header file for compilation Header files contain prototype and definitions of the functions and instructions used in a program
Some common header files are stdio.h, conio.h, stdlib.h, math.h, etc
All statements should be entered in small case letters C has no specific rules for the position at which a statement to be written
Main () Function
It is an entry point of the program
Printf() function
The printf() function is the standard way of C to display output on the screen.
getch() function
This is another function call it reads in a single character from the keyboard This command keeps the output window from closing
Rules
Each instruction in a C program is written as a separate statement. The statements in a program must appear in the same order in which we wish them to be executed. Blank spaces may be inserted between two words to improve the readability of the statement, (no blank spaces are allowed within a variable, constant or keyword)