C Programming

An introduction

home next

A SIMPLE C PROGRAM
The following program is written in the C programming language.


	#include <stdio.h>

	main()
	{
		printf("Programming in C is easy.\n");
	}


	Sample Program Output
	Programming in C is easy.
	_


A NOTE ABOUT C PROGRAMS
In C, lowercase and uppercase characters are very important! All commands in C must be lowercase. The C programs starting point is identified by the word

	main()

This informs the computer as to where the program actually starts. The brackets that follow the keyword main indicate that there are no arguments supplied to this program (this will be examined later on).

The two braces, { and }, signify the begin and end segments of the program. The purpose of the statment


	#include <stdio.h>

is to allow the use of the printf statement to provide program output. Text to be displayed by printf() must be enclosed in double quotes. The program has only one statement


	printf("Programming in C is easy.\n");

printf() is actually a function (procedure) in C that is used for printing variables and text. Where text appears in double quotes "", it is printed without modification. There are some exceptions however. This has to do with the \ and % characters. These characters are modifier's, and for the present the \ followed by the n character represents a newline character. Thus the program prints

	Programming in C is easy.

and the cursor is set to the beginning of the next line. As we shall see later on, what follows the \ character will determine what is printed, ie, a tab, clear screen, clear line etc. Another important thing to remember is that all C statements are terminated by a semi-colon ;

Click here for a pascal comparison.


Summary of major points so far


ęCopyright B Brown. 1984-1999. All rights reserved.
home next