C has 32 keywords, these keywords cannot be used as variable name. Father of C programming – Dennis Richie. 16 bit compiler have integer range -32768 to 32767. C is a high level language with some low level features. C is primarily developed as system programming language
If integer need two bytes of memory to store then maximum value of unsigned integer is 2^16 – 1. If integer need two bytes of memory to store then maximum value of unsigned integer is 2^15 – 1. Zero is return to the operating system upon the successful completion of a program
C consist of four variable data types –
- char
- int
- float
- double
Array groups homogenous data into a single object. Structure groups heterogeneous data into a single object. Union is syntactically same as structure, in structure each member have separate memory location, but in union all member have same memory location. Enumerated data type specify possible values of a variable, by meaningful symbolic names
A declaration of a variable occurs once, but a definition may occur many times. Versatility of a computer is the ability to perform a set of instructions repeatedly. While loop is used to execute some instructions in fixed number of times. Do while initially execute the statement first then only check the condition. Continue statement in C take the control to the beginning of the loop (for, if,while) without executing the remaining part of the loop. Break statement in C take the control out of the loop (for, if,while) without executing the remaining part of the loop. Odd loop is a loop in which the number of times the statement should be executed is unknown
Typedef is used to redefine name of a variable, ++i will increment the value of i, and then return the incremented value. i++ will increment value of I and return the previous value of i. Function can return pointer, Recursion enhances logical clarity, Val is data flow language, Control statement doesn’t produce any object code when compiled
C has a formal grammar specified by the C standard, Structured programming is dividing the program into different program modules, C programming language non zero or non null is considered as true otherwise false, Sentinel is used to avoid infinite loops
Type casting – convert values of an expression to a particular data type
Goto is used to jump out of nested loop. Conditional compilation is done by pre processor and it is compiling a program based on the condition. Minimum number of temporary variables required to swap two variables is 0
Literal is a string constant. Sizeof (int) equals sizeof (unsigned). Coercion take place if an operator has operands of different data types. Coercion refers to implicit type conversion. Casting refers to explicit type conversion. C provides no input output features. C provides no file access features. C borrowed most of its features from BPCL. C provides no features to manipulate composite objects. Integer division results in truncation.
Value of EOF
- defined in stdio.h
- implementation depend
- can be negative
- should not be equal to integer equivalent of any character
Value of automatic variable that is declared and not initialized is unpredictable. An identifier may start and end with an underscore. IF is a valid identifier. Number of significant characters depends on implementation. Constant expressions are evaluated at compile time. String constants can concatenated at compile time. Size of array can be find out at compile time. Const feature can be applied to array, array argument and identifier,
functions of various operators.
- || operator stops when one of the components evaluate to true
- Right to left associativity in all relational operators, prefix increment/decrement, unary plus/minus, sizeof, *, &, ?:
- * & # are context depend operators
- ++ cannot be applied to an expression
- ++ is unary
Code used to ring the bell
Printf (“%c”, 100); print the ASCII value of 100
Int i = 263;
putchar (i);
Important Points to be noted for programming
- Scanf(with %s option) will delimit with blank space
- Main, printf, IF are not keywords in C
- In a for loop if condition is absent then it assume to be present and taken to be true ; infinite loop can be avoided by break statement, goto statement, return statement
- 0 represents a false condition
- Body of for loop can be empty
- In for loop if comma is used then returned value is right operand value
- In for loop Index value is changed with in the loop and retained outside the loop
- Nested for loop cannot overlap
- If switch feature is used then default case can placed anywhere
- Switch feature can be replaced by a nested if then else clause
- Switch feature enhances logical clarity
- The number of number of subscripts shows the dimension of array
- All the elements in the array have same data type and storage class
- If storage class is missing in array then default by either automatic or external depending on the location of occurrence
- Volatile is a feature of C to provide reliable access to special memory locations
- Parameter passing mechanism for an array is call by value
- Maximum dimension of array in C depends on compiler
- If one dimensional array is actual argument then its size should not be mentioned
- An array element may be an array itself
- Strictly speaking, C supports one dimension array only
- The order in which actual arguments in a function is called depends on compiler
- Two local variable may have same name
- Scope of a local variable may be a single statement
- During external variable definition storage is set aside by compiler
- During external variable declaration no storage is set aside by compiler
- Use of external variable make debugging difficult
- Storage class static can provide privacy to set of functions
- Storage class static preserve the exit value of variables
- Body of a function may have many returns
- A function only can return one value to the calling environment
- Storage class defines the scope and permanence
- Printf(“ab”,”cd”); – Prints only ab
- Before using pointer variable it should be declared and initialised
- Address variable & cannot act on R value and arithmetic operations
Order of precedence of operators in C, operations are executed according to the order of precedence, order of precedence is given below
- Postfix ()[]
- Unary + – ! ++ —
- Multiplicative * / %
- Additive + –
- Shift << >>
- Relational
- Equality
- Bitwise AND &
- Bitwise XOR ^
- Bitwise OR |
- AND &&
- OR ||
- Conditional
- Assignment
- comma
Contents