You are on page 1of 9

COMPUTER

[Commonly operated machine particularly used for technical educational and research]

 A computer is nothing but a device which is performing calculations.


 Mr. Charles Babbage is an English man led the foundations for modern computer science in
1821.
 The first electronic computer invented by J.P.ECKERT and J.W.MAUCHLY belongs to U.S.A in the
year of 1946. Named as ENIAC{Electronic Numeric Integrated And Calculator}.
PROGRAM
 This is a set of instructions.
 SOFTWARE;- Set of programmes.
 SOFTWARE TECHNOLOGY;- The knowledge of the applications of the computer such as how to
work with the languages as well as packages.
 HARDWARE TECHNOLOGY;- The knowledge of the physical parts of the computer or the
mechanism of the physical parts of the computer.
 O.S(operating system);- It is a set of programmes which act as an interface between user and
hardware as well as which provides an environment to execute the user commands.
O.S is the manager for both software and hardware.
 LANGUAGES;- These are used to communicate with the system in order to construct the
programming structure.
 PACKAGES;- It is a pre defined programme designed by somebody else and used by us.
HISTORY
 COBOL-(Common business oriented language);- This is used for developing business and
commercial purpose programming.
 FORTRAN-(Formula translation);- This is used for developing scientific and engineering purpose
programming.
 The international committee designed a programming language by taking the both features of
COBOL and FROTRAN named as C.P.L(Combined Programming Language) used for developing
wide range of programme but lengthy.
 In order to reduce the length of the programme they designed another programming language
named as B.C.P.L (Basic Combined Programming Language) which is not efficient.
 In order to increase the efficiency Mr. Ken Thompson designed a programming language named
as ‘B’-language which is machine dependent.
 In order to make machine independent programming language Mr. Dennis Ritchie developed a
programming language at AT & T (American Telephonic And Telegraphic) bell labs U.S.A in the
year of 1970 named as ‘C’-language.

WHY ‘C’ IS?


 With the help of ‘C’-language we can develop the wide range of programming.
 Not to write the lengthy programme for small calculations.
 The programmes are executing with high efficiency.
 It is portable or transportable or independent.
TRANSLATOR
 The main functionality of the translators are used to translate the source code (S.C) to object
code (O.C).
 Source code is nothing but the code which is written by the user in the high level language.
 Object code is nothing but machine understandable code.
 The translators are classified in to 2 categories.
1. Interpreters
2. Compellers
 The interpreters are used to translate source code to object code consequently. If at all any
errors are occur the programme execution will stops over their till it is error free.
 Whereas compellers are used to translate source code to object code in a single shot. If at all any
errors are occur those are isolated in the next screen.
1. ‘C’ TOKENS

 The smallest individual component in the programme known as token.


 The 'C’ language will offers the following tokens;-
1. ‘C’ Character set
2. Variables.
3. Data types.
4. Constants.
5. Operators.
6. Identifiers.
7. Keywords.

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;-

 What type of data to be present in the specified variable.


 The ‘c’ language will offers the following data types.
1. INTEGER.
2. FLOAT.
3. CHARACTER.
4. DOUBLE.

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;-

 It will allows you to store a character or string(group of characters).


 Its range is -128 to +127.
 It will take 1 byte space in memory.
 It is represented by “char’.

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;-

 It will allows you to store a number larger than the float.


 Its range is 1.7E-308 to 1.7E+308.
 It will take 8 byte space in the memory.
 It is represented by "double”.

EXECISE 1;-

Declare variables to store student number, student name and age.


Int sn;

cha sname[30];

int sage;

Declare variables to store employ number, employ name and salary.

int Eno;

cha Ename[40];

float Esalary;

OPERATORS;-

 It is a symbol used to operate the operands.


 Operators are classified into 2 categories.
1. Unary operator.
2. Binary operator.
 Unary operators are used to respond on a single operand.
 Where as the binary operators are used on more than one operand minimum of two.

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

 Which are used to perform all arithmetic expressions.

S.NO OPERATOR MEANING ACTION RESULT let a=10,b=5

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

a=2, b=3, c=5


d=a+b*c; =17 according to ‘BODMAS’ rule.

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).

S.NO OPERATOR MEANING ACTION RESULT let a=10,b=5

1. > G.T a>b 1


2. < L.T a<b 0
3. >= G.T or E.Q a>=b 1
4. <= L.T or E.Q a<=b 0
5. == EQUALS TO a=b 0
6. != NOT EQUAL a!=b 1

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(&&)

Exp1 Exp2 Result

T F F As per ‘AND’ structure when all the conditions are true

F T F then only it will execute true statement other wise it

F F F will execute false statement. The AND operator double

T T T ampersand.

a=10 => (a>b&&a>c) => 0


b=30 =>(b>a&&b>c) => 1
c=15 => (c>a&&c>b) => 0

OR(“)
Exp1 Exp2 Result

T F T As per ‘OR’ structure when all the conditions are false

F T T then only it will execute false statement other wise it

F F F will execute true statement. The OR operator double

T T T (“).
ASSIGNMENT OPERATOR;-

 Which is used to assign a value or an expression.


 Assignment always will takes place from RIGHT to LEFT.
 Assignment operator is “=” (single equals to).
M1 =60;

m2=50;

m3=m1+m2;

m1=60;

m2=60; implies m1=m2=m3=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”)

INCREMENT AND DECREMENT OPERATORS;-

 The increment operators are used to increase by a value.


 The increment operator is “++”
 The decrement operators are used to decrease by a value.
 The decrement operator is “--“
Int x=10;
Y=x+1; or y=x++;

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;-

 Which return the size of the specified variable or data type.

COMPOUND OPERATORS;-

 Which are works same like as arithmetic operator only.


 It is the combination of both arithmetic operator and assignment operator.
 Another name of the compound operator is “shortcut operator”.

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
{

 The list of variable must be separated by coma.


Int m1;
Int m2; int m1,m2,m3;
Int m3;
 Every statement must be terminated by semi column.
 Every function name must be followed by the couple of parenthesis.().
Clrscr()
Printf()
Scanf()
Getch()
 While comparing or assigning a character should be taken in single quotation marks. ‘s’.
 While comparing or assigning string should be taken in double quotation marks. “kaladhar”.
 The comment should be taken in between /* and */
STRUCTURE OF ‘C’ PROGRAMME.
/*comment section*/
File inclusions
Pre processive directives
Global declarations
[void]main()
{
Statement1;
Statement2;


Statement n:
}
Function1()
{
[logic variables];
Statement(s);
[return<variable>];
}


Function n()

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);

You might also like