The if Statement

The if statement is used to control the flow of the execution of statements in program. The general form of the if statement is
if (test condition)
The condition to be evaluated is placed in a pair of parenthesis immediately following the keywords if. First, the test condition is evaluated. If it is true then the statement (or set of statements) following if are executed. If the condition evaluates to false, the statement(or set of statements) following if are skipped.Thus there is a two way branching for the if statement: One for the true and the Other for the false condition.

Operator in C

An operator is a symbol which tells the computer to perform certain mathematical or logical manipulations. The operators are used in mathematical and logical expressions.
Operators in C are classified as under:
  • Arithmetic Operators
  • Relational Operators
  • Logical Operators
  • Assignment Operators
  • Increment and Decrement Operators
  • Conditional Operators
  • Bitwise Operators
  • Special Operators

Primary Data Types

The four fundamental or primary data types are:
  • Integer(int)
  • Character(char)
  • Floating point(float)
  • double precision floating point(double)
These primary data types themselves are of many types. eg. integers could be long or short, signed or unsigned etc.

Variables

A variables is a data name used to store a data value. Variable names are names given to location in the memory where different constants are stored. Unlike a constant which remains unchanged during the execution of a program, a variable can take different values at different times during execution.
A variable name is a combination of alphabets,digits or underscores. The first character however must be an alphabet. No commas, or blank are allowed while constructing variable. The variable name should not be keyword. Variables are case sensitive i.e. sum and SUM are two distinct variables.
Some valid variable names are:
Max_length age xyz avg a1 T1

Constants

A constant in C is a fixed value which does not change during the execution of a program. C support several types of constants as under:
The basic classification of constant is:
Numeric Constants and Character Constants
These are further classified as:
Numeric Constants:
  • Integer
  • Real
Character Constants:
  • Single Character
  • String

Identifiers

Identifiers are names given to variables, functions and arrays. These are names which are user defined. They are made up by a combination of letters and digits. Normally an identifier should not be more than 8 characters long. The use of underscore is also permitted in identifiers.However, it is imperative that identifiers should begin with a letter.
Some example of identifiers are:
min1
max_temp
temp() etc.
C does not permit use of blank space, tabs, commas or special characters in identifiers.Thus:
min1
max*temp
12temp
are invalid identifier in C.

Keywords

Keywords are words whose meaning have already been defined and these meaning cannot be changed. Keywords are also called as reserved words. Keywords should not be used as used variable names (though some compilers allow you to construct variable names like keywords). All the keywords must be written in lowercase.

These are 32 Keywords in C as given below:

  • auto
  • double
  • if
  • static
  • break
  • else
  • int
  • struct
  • case
  • enum
  • long
  • switch
  • char
  • extern
  • near
  • typedef
  • const
  • float
  • register
  • union
  • continue
  • far
  • return
  • unsigned
  • default
  • for
  • short
  • void
  • do
  • goto
  • signed
  • while




C Tokens

The smallest individual units in a C program are called tokens. The alphabets,numbers and special symbols are combined to forms these tokens.
The types of tokens in C are:
-Keywords
-Identifiers
-Constants
-Strings
-Special Symbols
-Operators

What is a C program ?

C has only 32 keywords but a number of built in function. Thus a C program is basically a collection of function which are supported by the C library. We can make efficient use of these function in our programming task. One can also add new functions to the library.
Example: The first C program
main()
{
/* The First C Program */
printf("\nMy First C Program");
/* end of program */
}

The Output of this program will be:
My First C Program

Features of C

The C programming language was developed at AT &T's Bell Laboratories in USA in 1972. This language has been designed and written by Dennis Ritchie. C is a very Robust programming language and has a rich set of built in function. C is simple to learn and easy to use. C language is suitable for writing both system software and application programs and business packages. The Unix operating system was also developed at Bell Laboratories around the same time. Thus C is Strongly associated with Unix. In fact, Unix is coded almost entirely in C.