You are on page 1of 26

Any corrections let me know

OVER VIEW

COMPUTER TECH
Hardware tech Software Tech

Software Programmes Instructions

Applications

System Software

Language

Progamming Language {PL}

GPL

BASIC DEFINITIONS
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 command OS is acting as manager for both software and hardware resources Package : It is a predefined programme designed by somebody else and used by us Language : Which are used to communicate with system inorder to construct the programming structure Why C is ? *It supports to develop wide range of programmes *Doesnot require to write lengthy programmes for small calculations *The programmes are executing with high efficiency *C programmes are portable and transportable or machine independent

HISTORY OF LANGUAGES
*COBOL (COmmon Bussiness Oriented Language) was the first language introduced.The name itself suggests that this language was for bussiness purpose
**So this is not useful for Engineering purpose

*FORTRAN (FORmula TRANslation) this was the second language after COBOL .This is very useful in Eng.. purposes
**This is not useful for Bussiness Purposes

*C.P.L (Common Programming Language) this was the language that was introduced to fill the drawbacks of first two.This is useful for both bussiness and Engineering purposes
**But this language requires a lot steps to execute a small work

*B.C.P.L (Basic Common Programming Language) this language can execute work's in verl less steps
**But This language was found not to execute that effectively (in terms of speed)

*B-Language was developed at Bells lab and this was found to satisfy the drawbacks of B.C.P.L and the letter B was take from B.C.P.L **But this was a machine dependent language(which means In Olden
days there were 3 types of computer's Mini,Micro,Mainframe.The programme developed in mini was found to execute in mini only and silimar)

**Hence after all the above draw backs have been filled a machine independent language was introduced by Dennis Ritchie at "AT&T " in 1970 but it became popular after 2 years i.e 1972 **C language is the language: "C is a high level language "Which is useful for bussiness as well as Eng. purpose "It executes works in less steps and very fast "This is a Machine Independent language "It is portable and transportable

TYPES OF LANGUAGES

Assembly language HIGHLEVEL LANGUAGE MACHINE LANGUAGE This language


This is the language includes Binary digits and even that is understood symbols (+,-,*) by machine.Binary Digits (0 & 1) are used in this language This is also called as Lowlevel language Binary Language The code written using this lang is called object code OBJECT CODE
TRANSLATOR

This is the language which can be understood by the programmer (a-z,0-9 .!@$......) The code written using high lvl lang is called source code

SOURCE CODE

TRANSLATOR
Translators are those which are used to transulate the source code to object code (where source code is code written by us in high level language where as object code is nothing but the code which is machine understandable

TRANSLATOR

INTERPRETERS
Interpreters are used to transulate source code to object code consequently (step by step) .If at all any errors are occured the programme execution will stops over there till it is error free

COMPILERS
The Compilers are used to transulate source code to object code in a single attemptif at all any errord are occured they are isolated on seperate screen

1. C-TOKENS
*A taken is nothing but the smallest individual component in the programme to understand the C-Language we need to aware os the following tokens. i) Character set ii) Variables iii) Data types iv) Operators v) Identifiers vi) Keywords #Character set : The C lang can understand only ASCII(American Standard Code for Information Interchange) Character set. Whose range is from 0 to 255 which includes A-Z,a-z,0-9,Special Characters A-Z (65 to 90) a-z (97 to 122) 0-9 (48 to 57) Space bar (32) Enter Key ( 13) Escape (27)

#Variable : A space to stor data while execution of

programme (Simple definition) It is a memory allocation which enables you to store the data temporarily during the programme execution.In another words a space to store data Syn:<datatype> <variable>

##Data types : It represents the type of value s to be


presented in the specified memoery Integer(Signed Integer) : It allows you to store a number without decimal(sequence of didgits) It will take 2 bytes of space in the memory Its range is -32768 to 32767 It represents with "int" Note : By default Integer is a signed integer Ex: int studentno; or signed int studentno;
Unsigned Integer : Allows you to store a number without decimal It will take 2 bytes of space in memory Its range is from 0 to 65535 It represent's with "unsigned int" Ex ; unsigned int HallTicketNo; Values :12u,234u,etc Here u makes them as Unsigned Interger as system take only "12" as a Integer(Signed Inter)

Long Integer : It allows you to store a number without decimal It will take 4 bytes of space It is represented with "long int" whose range is from -2,147,483,648 to 2,147,483,647 Eg ; lont int oldbalance; Values:5456l,-2346l

Will take 4 bytes of space in memory Its range is from 0 to 4,294,967,295 Ex; unsigned long oldblance; Values :45678lu,234567lu

Unsigned Long ; Allows you to store a number without decimal

values,Exponential values It will take 4 bytes of space in the memory whose range is from 3.4e^38

Float:It allows you to store the real numbers i.e Scientific

It is represent's with "float" Ex:3.14f,4.3445f,27.000000(6 decimal places only)

It will take 8 byte space in the memory whose range is 1.7e^308 Ex:3.14lf

DOUBLE: It allows you to store a number with decimal

10bytes space in memory . Its range is 3.4e^4932

LONG DOUBLE : It allows you to store a number with decimal it will take

CHARACTER
>It is classified into two types Signed Character and Unsinged Character >Both signed and Unsigned will take 1 byte space in the memory >Range of unsigned character is 0 to 255 Range of Signed character is -128 to 127 Note: By default Character Data type will take 1 byte space in memory adn hence it will store only 1 character And if we need need more than one character then we need to specify the no.of characters in "[<number>]" besode data type Ex ; char SName; <- This will allow to store only 1 charcter Ex: A,B,C,If we type "Ravi" It will take only "R" char SName[20]; <- This will store upto 20characters

Excercise 1: 1.Declare the varaible to store Student Name,Hall Tick No, S City Sol. unsigned int HallTicketNo; char SName[30]; char SCity; 2.Declare the varaiable to store Employ Name,Job,Salary, date of joining. Sol. char EName[30]; char Job[30]; long int salary; char date[10]

OPERATORS
Operators are those which are used to perform the operation on the operants.Usually operators are of two types : 1)unary operators 2)Binary Operators >An Operator which is used to perform the operation on single operant is called as Unary Operator Ex; X++ >Where as which performs the operation over two operants are called Binary Operator Ex: X+Y

TYPES OF OPERATORS ARTHIMETIC OPERATOR RELATIONAL OPERATOR LOGICAL OPERATOR ASSIGNMENT OPERATOR
CONDITIONAL OPERATOR INCRIMENT OR DECREMENT OPERATOR

SIZE OF OPERATOR
COMPOUND OPERATOR

Arthemaitc Operators : which are used to perform all arthematic operations


BODMAS ORDER ; ()/x+-

OPERATION

MEANING

ACTION

RESULT a= 10 b= 5

+ x / %

ADD SUB MUL DIV MOD

a+b a-b axb a/b a%b

15 5 50 2 0

a=2 b=3 c=5 d = a+bxc 17 d=(a+b)xc 25

int X=5;float y; y=5/2; Exp output ;2.5 Act output 2.0 int/int =>int int/float =>float float/int =>float float/float =>float 5/2 = 2 5/0.2f=2.5 5.0f/2=2.5 5.0f/2.0f=2.5

But priority in C Lang will not be as BODMAS here is the order of priority Ist Priority => /x% IInd Priority => +IIIrd Priority => =

Relational Operator : Which are used to check the relation among Operators.It will return values in BOOLEAN values (0 for false 1 for true) The Evaluation will be from left to right
OPERATION MEANING ACTION RESULT a= 10 b= 5

> < >= <= == !=

GT LT GT Eq LT Eq Equal Not Eq

a>b a<b a>=b a<=b a==b a!=b

1 0 1 0 0 1

a=10 b=20 Ex; c=a>b (0) Left to right ---> -----------------------------c=2<3!=10 Step1 1!=10 Step2 1 Step3 -----------------------------

LOGICAL OPERATOR ; =>Enables you to work with more than one condition =>AND,OR,NOT are Logical Operators AND=> When all the conditions are true then only we will get true and in all other cases false Symbol :- && OR => When all conditions are false then only we will get false or else true Symbol :- l l
a = 10;b =20;c=30;
EXP1 AND EXP2 ACTION RESULT

(a>b)0 (b>a)1 (c>a)1

AND AND AND

(a>c)0 (b>c)0 (c>b)1

(a>b)&&(a>c) (b>a)&&(b>c) (c>a)&&(c>b)

0 0 1

a = 10;b =20;c=30;
EXP1 OR EXP2 ACTION RESULT

(a>b)0 (b>a)1 (c>a)1

OR OR OR

(a>c)0 (b>c)0 (c>b)1

(a>b)l l(a>c) (b>a)l l(b>c) (c>a)l l(c>b)

0 1 1

Examples: Case 1 : (a>b)&&(a>c) l l (c==c&&a!=a) 0 && 0 l l 1 && 0 0 ll 0 0 Case2 : (2+3!=5)&&3>2)&&(3+2<5 l l 5+5<10) 0 & 1 && 0 ll0 0 && 0 0 Assignment Operator : =>Used to assign a value or an expression .It is always from (right to left) Symbol :- == Syn :- <data type> <variable name> x=10 int x;Variable decleration y=20 x = 100; initial z =30(x+y) int x=100 -> variable decleartion cum Initial int x=y=z=30 ; Multi declerational cum initial

Conditional Operator : Which will check the initial condition initially.If the condition is true it will execute logical true (or) If the conidition is flase it will execute logical falselogical false.It is also known as Terminary Operator Symbol :- "? and :" Syn : (<condition>)?LOGICAL_TRUE : LOGICAL_FALSE a=10 b=5 Ex:Marks = 67 (Marks>34)?printf("PASS") : printf("FAIL"); or (Marks<34)?printf("FAIL") : printf("PASS") Ex2: a=2 b=3 c; (a<b)?c=a+b : c=a*b; //invalid c=(a<b)?a+b:a*b; // valid Output=5 Increment or decrement operators : >Increment operator used for increase by a value >>Symbol : ++ Ex; y+1 or y++ >Decrement operator used for decrease by a value >>Symbol : -Ex: y-1 or y--

Both Increment or Decrement operators are classified into 2 catogaries 1)Preincriment or Predecrement 2)Postincriment or Postdecrement In preincriment or Predecrement values of variable will be increased or decreased by 1 before initilisation where as postincrment or post decrement values of variable will be increased or decreased by one after initilisation. Increment Pre inc : ++x Post inc : x++ Decrement Pre Decr : --x Post Decre : x-x y z 10 20 30 y=++x 11 11 30 x y z 10 20 30 y=x++ 11 10 30

x y 10 20 y=++x 11 11

x y 10 20 y=x++ 11 10

Hence clearly we can see that these both are different The case in which they both give same result is as below : x x 10 10 x++ 11 ++x 11 Only in this case they are same Example:
STEP OPERATION x y z

10 Step1 Step2 Step3 Step4 y=++x x=--y z=++x y=x++ 11 10 11 12

20 11 10 10 11

30 30 30 11 11

Note;Here every step is written from its above step which step 1 is from basic and step 2 is from step1 and so on

Sizeof Operator : Which returns size of the specified variable or a datatype Ex: int x; printf("%d",sizeof(x)): printf("%d",sizeof(float))://4 printf("%d",sizeof(clrscr()))://2 Compond operators: =>It is combination of both arthematic and asiignment operators it will work similar with arthematic operators also known as shortcut operators.

OPERATION
+= -= *= /= %=

ACTION
x+=10 y-=x n*=m n/=m n%=m

Mean
x=x+10 y=y-x n=n*m n=n/m n=n%m

Identifier : A variable is nothing but space to store data where as an identifier is nothing but a name given to a space alternatively all the names which are designed by us for programming conviency

Limitations : 1)An identifier must begin with an alphabhet 2)It length do not exceed32 characters 3)It may be in upper case or lower case or middle case 4)It may have a special character is an "_" Underscore Note : Two consequetive underscore should not be used. 5)It may have digits 6)It must not be C Land related keyword

Keywords : =>Keywords are nothing but reserved words =>The meaning of words is already defined to the compiler =>Every keyword is having its own importance

asm break case cdecl char const continue default do double else enum extern far float for goto huge if

int interrupt long near pasis register return short signed sizeof static struct switched typedef union unsigned void volatile while

STRUCTURE FOR C-PROGRAMMING

/*comment Section*/ File inclusions Pre processor directives Global Declarations void main () { [local variables] Statement(s); =========== } [<return type>] <functionname><[list of arguments]> [local variables]; statement(s); [return <variable/exp/value>];

COMMENT SECTION : =>In comment section we can write anything related to the programme we can write the comment section. =>we can write the comment section any wher in programme and any no.of times whatever the statements which are taken in between /* and */ those lines are ignored by the compiler =>comment witin comment is not supported in the C-Complier

FILE INCLUSIONS : =>A library is nothing but collection of functions =>In C-Language we have varies libraries for performing various operations =>while working with any function in programme it is recommended to use corresponding library name as a file inclusion Ex; C-language
Stdio.h printf() scanf() String.h Conio.h strlen()
File Inclusion

........ strupr()

Ex: /*To print a msg*/ #include <stdio.h> void main() { printf("This is C Notes) }

INPUT AND OUTPUT FUNCTIONS : *Input functions are used to take the values from input device and assign to specific variables Eg: scanf() where f stands for format *Output functions are used to read the values from variables and display it on the screen Eg:printf() where f stands for format.

You might also like