60 likes | 136 Views
Computer Programming 0455-3391-01. A simple example. /* HelloWorld: A simple C program */ #include <stdio.h> int main (void) { printf (“Hello world!<br>”); return 0; }. A simple example. /* HelloWorld: A simple C program */ #include <stdio.h> int main (void) {
E N D
A simple example /* HelloWorld: A simple C program */ #include <stdio.h> int main (void) { printf (“Hello world!\n”); return 0; }
A simple example /* HelloWorld: A simple C program */ #include <stdio.h> int main (void) { printf (“Hello world!\n”); return 0; } • This is a comment • comments help explain the program to someone • they are ignored by the computer
A simple example /* HelloWorld: A simple C program */ #include <stdio.h> int main (void) { printf (“Hello world!\n”); return 0; } • This is an instruction to the compiler to insert the contents of a file named “stdio.h” into the program • supplies useful information for the compiler
A simple example /* HelloWorld: A simple C program */ #include <stdio.h> int main (void) { printf (“Hello world!\n”); return 0; } • This tells the compiler we’re about to define a function, named main • main is a special function; it is where your program starts running
A simple example /* HelloWorld: A simple C program */ #include <stdio.h> int main (void) { printf (“Hello world!\n”); return 0; } • This is a C statement • This statement calls a function named printf • It causes the text to be printed on the screen