13-05-2013, 02:41 PM
C Programming
C Programming.pdf (Size: 390.57 KB / Downloads: 363)
Computer Languages
• Machine Language: A Binary Language composed of 0s and 1s –
that is specific to each computer.
• Assembly Language: Binary & Mnemonics based.
• High Level Language: machine-independent.
The C Language
• C is a robust language whose rich set of built-in functions and
operators can be used to write any complex program.
• C compiler combines the capabilities of an assembly language with
features of high-level language and therefore it is well suited for
writing both system software and business packages.
• Programs written in C are efficient and fast .This is due to its variety
of data types and powerful operators.
C variables
• Variable names are names given to the memory locations of a
computer where different constants are stored.
• These locations can contain integer, real or character constants.
• The rules of constructing variable names of all types are same.
– A variable name is any combination of 1 to 8 alphabets, digits or
underscores.
– The first character must be alphabet.
– No commas and blanks are allowed within the variable name.
– No special symbol other than an underscore can be used in a variable
name.
sizeof operator
• The sizeof is a compile time operator and,when used with an
operator, it returns the number of bytes the operand occupies
• The operand may be a variable,a constant or a data type qualifier
Eg: int m,n, sum;
m=sizeof(sum);
n=sizeof(long int);
• The sizeof operator is normally used to determine the lengths of
arrays and structures
• It is also used to allocate memory space dynamically to variables
during execution of a program
Control of Loop Execution
• A loop construct, whether while, or do-while, or a for loop continues
to iteratively execute until the loop condition evaluates to false.
• The break statement is used to exit early from all loop constructs
(while, do-while, and for)
• The continue statement used in a loop causes all subsequent
instructions in the loop body (coming after the continue statement) to
be skipped.