You are on page 1of 12

ddo

#include<stdio.h>

main()
{
printf("Hello World\n");
return 0;
}

ddo

#include<stdio.h>
This includes a file called stdio.h which lets us
use certain commands.
stdio is short for Standard Input/Output which
means it has commands for input like reading
from the keyboard and output like printing things
on the screen.

ddo

main()
main is the name of the point where the program
starts and the brackets are there for a reason that
you will learn in the future but they have to be
there.
All programs must have a main function

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

/*

this comment runs to the terminating


symbol, even across line breaks

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

Execute program and


evaluate results

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

You might also like