Home | About | Comments | Lectures | Notice | Registration
A Simple C Program - Hello World
You Will Learn About :
The material provided on this site is part of a complete course in Mastering C Programming. C programming at introductory level is FREE.
A C program is made up of one or more of functions. A function is a group of related statements. One function must be named main( )
There are rules for all spoken languages. C a computer language also has rules which the programmer must observe.
Here are some to commit to memory.
/* Program 1A - Hello Program */ main() { printf("Hello, world"); } |
Instructions :
Detailed Explanation :
C does not care how the program is written as long as all of the syntax rules are followed. The next program, Program 1B , looks bad to the reader but not to the C compiler
The compiler is the program which converts the code you write ( source code ) into object or machine code which the computer "understands". We need to present our code in a readable format for the benefit of other programmers and ourselves but the computer does not care.
/* Program 1B - Fun Program */ main(){printf("this is fun");}
The sequence `\n' is C notation for "newline character", which, when printed, skips the terminal to the beginning of the next line. Notice that `\n' represents only a single character.
/* Program 1A - Hello Program */ main() { printf("I am glad \n to be learning C programming"); } |
The \n newline character forces the words "to be learning C programming" to begin on a new line.
1. Change the contents of the printf( ) string to "Programming is fun"
2. Include your name and address within the same printf() statement but on a new line
The Tutor |
|
Home | About | Comments | Lectures | Notice | Registration