Professional Documents
Culture Documents
L2a Hello World PDF
L2a Hello World PDF
#include<stdio.h>
main()
{
printf("Hello World\n");
return 0;
}
ddo
#include<stdio.h>
ddo
main()
ddo
{}
The 2 curly brackets are used to group all the
commands together so it is known that the
commands belong to main. These curly
brackets are used very often in C to group
things together.
ddo
printf("Hello World\n");
This is the printf command and it prints text on the screen.
The data that is to be printed is put inside brackets.
ddo
Comments in a program are called inline
documentation
They should be included to explain the purpose
of the program and describe processing steps
They do not affect how a program works
C comments can take two forms:
// this comment runs to the end of the line
ddo
Spaces, blank lines, and tabs are called white
space
White space is used to separate words and
symbols in a program
Extra white space is ignored
A valid C program can be formatted many ways
Programs should be formatted to enhance
readability, using consistent indentation
ddo
#include <stdio.h>
main() {
// comments about the program
printf(“Hello World! \n”); }
ddo
Edit and
save program
errors
errors
Compile program
ddo
The syntax rules of a language define how we can
put together symbols, reserved words, and
identifiers to make a valid program
The semantics of a program statement define what
that statement means (its purpose or role in a
program)
A program that is syntactically correct is not
necessarily logically (semantically) correct
A program will always do what we tell it to do, not
what we meant to tell it to do
ddo
End
ddo