C ENTRAL P ROCESSING U NIT (CPU) Chapter 2. H ISTORY OF PROCESSOR 2 PCM Chapter 3: CPU.
Cpu-fundamental of C
-
Upload
suchit-patel -
Category
Presentations & Public Speaking
-
view
428 -
download
0
Transcript of Cpu-fundamental of C
Fundamental of C Programming Language
Header Files
Header files contain set of predefined standard library functions that we can include in our C programs. But, to use these various library function, we have to include the appropriate header file:
Examples: #include<stdio.h> is a header file that
consists of standard input/output like printf(), scanf()etc.
Character Set
Tokens
Keywords
C language has 32 reserved keywords.Since keywords have specific meaning, we
cannot use them as identifiers.All keywords are to be written in lower-case.
Identifiers
They are use for naming variable,functions and arrays.
Variables
A variable is an identifier that is used to store a data value.
It is a symbolic name assigned to the memory location where data is stored.
Example : int a = 7; 7 3 -98 Garbage value
int b = 3; a b c int c ; • A variable can have only single data item at
any given time during the program executio.
Constants
Constants are the identifier that represent fixed values. Integer Constants: It’s an integer valued number. It consists a sequence of digits.
Floating-point Constants: These represent numbers containing
fractional parts.• Character Constants:
It is a single character, enclosed in
apostrophes (single quotation marks). Several character constants and their ASCII values are shown below.
The Digraph and Trigraphs
In computer programming, digraphs and trigraphs are collection of sequences of two and three characters respectively. Mostly they appear in source code, which a programming language specification requires an implementation of that language to treat as if they were one other character.
Data Types
In C, every variable has a data type. Data type specifies the size and type of the value stored in that variable.
Fundamental Data Type/ Primary Data Type
These data types are also called as primary or built-in or basic data types.
The modifiers signed, unsigned, long and short may be applied to character and integer basic data types. However, the modifier long may also be applied to double.
Operators
Arithmetic Operators: These are binary operators as they take two operands. And
the operands must be numeric values. When both operands are integers, the result is integer. i.e. an
integer division result in truncation towards zero. If one is floating point and other is integer, the result is
floating point.
Relational Operators
The associativity of these operators is left to right.
Logical Operators
Logical operators are used to check 2 or more different conditions and take decision according to their values. Below is the list of possible conditions:
For &&
• In this case, the result is True only if both the conditions are true.
For ||
• In this case, the result is False only if both the conditions are False.
For !
The logical NOT operator takes single operand and reverses the value of the expresssion.
Assignment operators
The equal to(=)is an assignment operator.
Unary operators:
Unary operators require only one operand.there are 7 unary operators in C.
All unary operators are used as prefix except the increment and decrement.
Conditional Operator
This operator is used to check conditions and depending on the result, the statement is executed else we go for another execution.
Conditional operators are used in place of if-else statement.
This operator is also called as ternary operator as it takes 3 operands.
Bitwise Operators
This is binary operator as it takes 2 operands.Both operands must be of same time.This operator is applied to each pair of bits
independent of other bits within the operand .
For &
For |
For ^ The XOR operator sets 1 in each bit position where its
operands have different bits and 0 where they are same.
One’s complement operator(~):It takes only one operand thus it is an unary operator.It inverts the bits of its operand i.e. each 1 is converted to 0
and vice versa.It’s used for encrypting the files.
Shift Operators
Shift operators are used to shift the bits either to left or right.
These operators take two operands. The first operands is the bit pattern to be shifted and the second is an unsigned integer, a number that indicates the number of places the bits are shifted.
1. Left shift operator(<<):This operator shifts the bits to the left.
2. Right shift operator(>>):This operator shifts the bits to the right.
Size of Operator
The size of operator is a special operator used to return the size of its operand in bytes.
Example:int i , j;j = sizeof(i);// It will give j=2. Since integer occupies 2
bytes and I is an integer.
THANKS…..