Professional Documents
Culture Documents
[Commonly operated machine particularly used for technical educational and research]
CHARACTER SET;-
The ‘C’ language offers ASCII(American Standard Code For Information Interchange) character
set.
It’s range is 0 to 255
VALUES;-
A to Z 65 to 90
a to z 97 to 122
0 to 9 48 to 57
Enter key 13
Esc 27
Space bar 32
The space occupied by 1 or 0 is called 1Bit.
4 Bits = 1 Nibble.
8 Bits = 2 Nibbles = 1 Byte.
1024 Bytes = 1 MB.
1024 MB = 1 GB.
1024 GB = 1 TB (Terabyte).
VARIABLES-;
It is a memory allocation which enable to store the data temporarily during programme
execution.
Simply it is a space to store the data.
Syn; <data type> space <variable name>;
DATA TYPES;-
INTEGER;-
It will allows you to store the sequence of digits(a number without decimal).
It will take 2 bytes space in the memory.
Its range is -32,768 to +32,767.
It is represented with “int”.
FLOATS;-
It will allows you to store the real numbers.[Scientific values or exponential values].
It will take 4 byte space in the memory.
Its range is 3.4E-38 to 3.4E+38.
It is represented by “float”.
CHARACTERS;-
NOTE;- As we know that the character will take by default only 1 byte that means which allows
you to store only 1 character. If you want to store more than 1 character we need to specify the
size along with the variable for only character data types.
DOUBLE;-
EXECISE 1;-
cha sname[30];
int sage;
int Eno;
cha Ename[40];
float Esalary;
OPERATORS;-
TYPES OF OPERATORS;-
1. Arithmetical operators.
2. Relational operators.
3. Logical operators.
4. Assignment operators.
5. Conditional operators.
6. Increment/Decrement operators.
7. Size of operators.
8. Compound operators.
ARITHEMATIC OPERATOR
1 + ADD a+b 15
2 - SUB a-b 5
3 * MULT a*b 50
4 / DIV a/b 2
5 % MOD a%b 0
D=(a+b)*c; =25
RELATIONAL OPERATORS
Which are used to check the relation among the operands and it will return Boolean values(0 for
false, 1 for true).
LOGICAL OPERATORS
Which are used to check more than one condition. The C language will offers the following
logical operators
1. “and” (&&)
2. “or”
AND(&&)
T T T ampersand.
OR(“)
Exp1 Exp2 Result
T T T (“).
ASSIGNMENT OPERATOR;-
m2=50;
m3=m1+m2;
m1=60;
m3=60;
CONDITIONAL OPERATOR;-
Initially it will check the condition if the condition is true it will execute logical true.
If the condition is false it will execute logical false.
It is also called ternary operator.
The operator is ?:
Syn: (<condition>)? Logical_ true :Logical false;
a=20;
b=40
(a>b)?printf(“A is big”):printf(“B is big”)
Int x=20;
Y=x-1; or y=x--;
Increment and decrement operators are classified into 2 categories.
1. Pre-increment, pre-decrement.
2. Post-increment, post-decrement.
SIZE OF OPERATORS;-
COMPOUND OPERATORS;-
IDENTIFIERS;-
It is user defined name for variables, arrays, functions, pointers, files, etc.
LIMITATIONS;-
It must begins with an alphabet.
Its length not exceeded to 32 characters.
May be in uppercase or lowercase letters.
It may have digits.
It may have a special character an under scroll.
It must not be the ‘C’ keyword.
KEYWORDS;-
The keywords are called reserved words.
The meaning of these words are already defined to the compeller.
The meaning of these words can’t be changed.
In the ‘C’ language we have 32 keywords.
They are int, float, char, double, signed, unsigned, if, else, switch, case, break, default, continue,
do, while, for, return, void, auto, static, extern, register, union, struct, typedef, file, enum...etc.
PUNCTUATION RULES FOR WRITING ‘C’ PROGRAMME
Usually all programming statements must be in lower case letters.
Every programme execution begins with main().
All the programming statements must be written in between open and close curly braces
{
COMMENT SECTION ;-
In the comment section we can write any thing related to our programme.
We can write comment anywhere and ‘n’ number of times in programme.
Whatever is written in between /* and */ is not compelled by the computer.
Comment with in the comment is not supported by the compeller.
INPUT AND OUTPUT FUNCTIONS;-
Input functions are used to read the data from the input device and assign to the specified
variable.
Scanf();
Output function are used to read the data from the variable and display it in the console.
Printf();
Both printf and scanf functions are supported by stdio.h (standard input output header file).
Syn: scanf(“control strings”,&variables);
Printf(“control strings”,variables);
CONTROL STRINGS
The control strings are used to control the data in memory such as entering the data into the
variable or reading the data from the variables.
Another name of the control strings is “format specifies”.
s.no data type control strings
1 int %d
2 float %f
3 char %c for single and %s for string.
4 double %lf
Int sno;
Char sname[20];
Scanf(“%d”,&sno);
scanf(“s”,&sname);
printf(“%d”,sno);
printf(“%s”,sname);
EXECISE 1
Write programme statement to store employ number, name, job and salary.
Int eno;
Char ename[20];
Char ejob[30];
Int salary;
Scanf(%d”,&eno);
Scanf(%s”,&ename);
Scanf(“%s”,&ejob);
Scanf(“%d”,&esalary);
Printf(“%d”,eno);
Printf(‘%s”,ename);
Printf(“%s”,ejob);
Printf(“%d”,esalary);
SHORTCUT(imp)
Int eno,sal;
Char ename[20],ejob[20];
Scanf(“%d%s%s%d,&eno,&ename,&ejob,&salary);
Printf(“%d%s%s%d,eno,ename,ejob,salary);