UNIT - I: Overview of C:C Language Elements, Variable Declarations and Data Types, Executable Statements,
General Form of a C Program, Arithmetic Expressions, Formatting Numbers in Program Output.
Selection Structures: Control Structures, Conditions, if Statement, if Statements with Compound
Statements, Decision Steps in Algorithms.
Repetition and Loop Statements: Repetition in Programs, Counting Loops and the while Statement,
Computing a Sum or Product in a Loop, for Statement, Conditional Loops, Loop Design, Nested Loops, do-
while Statement.
INTRODUCTION TO C LANGUAGE
C is a structured programming language.
It was developed by M. Dennis Ritchie in 1972 at Bell Laboratories.
It is considered a high-level language because it allows the programmer to concentrate on the problem at
hand and not worry about the machine that the program will be using.
While many languages claim to be machine independent, C is one of the closest to achieving that goal.
That is another reason why it is used by software developers whose applications have to run on many
different hardware platforms.
Structure of a C Program
Before we study the basic building blocks of the C programming language, let us look at a bare minimum C
program structure so that we can take it as a reference in the upcoming chapters.
Hello World Example A C program basically consists of the following parts –
Preprocessor Commands
Functions
Variables
Statements & Expressions
Comments
Let us look at a simple code that would print the words "Hello World" –
#include <stdio.h>
void main()
{
/* my first program in C */
printf("Hello, World!");
getch();
}
Let us take a look at the various parts of the above program −
The first line of the program #include <stdio.h> is a preprocessor command, which tells a C compiler
to include stdio.h file before going to actual compilation.