SlideShare une entreprise Scribd logo
1  sur  75
Computer (data processor) is a machine which executes the instructions (given by
the user) to processes the data (also given by the user) with a very high speed .
Computer
(Data Processor)
Instructions /
Program
Data
(Raw input)
Information
(Processed Output)
How to process ?
What to process ?
Program - A sequence of logically connected instructions coded in a particular language to
perform a specific task
Data : The material on which the program instructions operate
Data processing - capturing input data, manipulating data & representing output information
Computer
Characteristics of computer
•Automatic - works without human intervention once program and data is fed.
•Speed - High speed processor - billion( 109) or trillion(1012) instructions per seconds (BIPS)
•Accuracy - produces continues accurate results (errors in data / program  garbage )
•Diligence - free from monotony , tiredness and lack of concentration
•Versatility - capable of performing any type of task depending on the program given
•Power of remembering - Can store/retain huge amount of program, data and information
in a secondary memory and can recall it whenever required
• No IQ - Has no intelligence of its own - can not take its own decision
• NO feelings - Computers are devoid of emotions - judgments only made based on
instructions
•Evolution of computer generations  1,2,3,4,5 (Home Work)
Input
Device
Output
Device
Processor
Memory
(01001110010101)
Instructions +Data Information
(1) Inputting
(3) Processing - arithmetic & logical operation)
(5) outputting
Keyboard
Mouse
Microphone
Touch Screen
Camera
Scanner
Screen
Printer
Speaker
Organization
(2) storing (4) retrieving
Input
Device
Output
Device
Processor
Primary Memory
fast but small in capacity
Organization
Secondary Memory
slow but large in capacity
Book
Shelf
processing
save load
working
desk
Secondary memory
Primary Memory
Arithmetic Logic Unit (ALU)
Control Unit (CU)
Input Unit Output
Unit
CENTRAL PROCESING UNIT (CPU)
STORAGE UNIT (SU)
encoding
using input
interfaces
decoding
using output
interfaces
Program Data
Program Data
calculation and comparisons
coordinates all components
Storage Unit
Characteristic Primary / Main Memory Secondary / Auxiliary
Usage Essential for a CPU and
processing
Working memory
Not essential for CPU and
processing
Non-working memory
Location Mother Board or main
circuitry
Peripheral Unit
Speed High Low
Capacity Huge ( GB,TB) Limited (4GB , 8GB)
Storage Temporary Permanent
Storage Volatile Non Volatile
Cost High Cheap
Manufacturing technology Semiconductor devices
Binary Storage
0 1 0 1 1 1 1 0 0
1 1 1 0 0 0 0 0 0
1 1 0 0 0 0 0
byte = 8 bits (0)
word = 2 bytes = 16 bits (3,4)
double word = 2 words = 32bits
(6,7,8,9)
0
1
2
3
4
5
6
7
8
9
A
B
Types of programming Languages
Machine Level / Code
• Contains binary coded instructions from CPUs instruction set
• Processor can process them directly without any transformation. - executable
• Hardware dependent
• Programmer needs to know processor architecture
8B542408 83FA0077 06B80000 0000C383 FA027706 B8010000 00C353BB 01000000
B9010000 008D0419 83FA0376 078BD98B C84AEBF1 5BC3
Assembly Level / Language
• Mapping of human readable symbols of machine codes - mnemonics +operands
• One to one correspondence between assembly statement and machine code
• Is specific to hardware
Types of programming languages
High Level Language
• Machine (Processor) independent English like language with high level of abstraction
• Closer to natural language , easier to use and more understandable
• Non executable
•
Types of programming Languages
Program Development Tools
Object
Program
Executable
Program
Compiling
Source
Program
Linking
test.c
test.obj
test.exe
Standard
Libraries
object code
Header
Files
.LIB
.H
Editing
include
C Programming Development Environment
• A high-level programming language interpreted by another program at runtime
• Scripts are tasks written for environment & interpreted at runtime in a batch
• Script requires an interpreter or a virtual machine at run time
• Explicit compilation or linking phases are not needed
• Variables, functions, and methods typically do not require type declarations.
• Source code is present at run time and compiled into native object code.
•JavaScript, ASP, JSP, PHP, Perl, Python
Scripting Language
Natural Language
• Programming in terms of natural language sentences, e.g. English
• The smallest unit of statement in NLP is a sentence.
• In an NLP text every sentence compiles into a procedure call in the underlying high
level programming language such as MATLAB, Octave, SciLab, Python, etc.
Advantages and limitations of different levels of languages - Home work
Examples - Mathematica. , Wolfram Alpha , Inform7 , Thinknowlogy,
Characteristics of a good programming language -1
1. Responsiveness
• e.g. excel
• Read-evaluation –print –loop (REPL)
• there should be less steps between changing code and seeing results
• More steps in REPLs destroyed program flow
• Small-talk and LISP have powerful REPLs
2. Safety
• provided by compilers so that even a smallest error can be detected before
a program is run
• Languages data type system is often a source of programming error
• Haskell has a powerful type system
• Dynamic type setting is risky - you need to run the program
3. Speed
• Sometimes we need the compile code that runs fast …
• It depends on language and memory layout or structure
• Best way to speed up code is to improve the algorithm
• C is the fastest high level language
Characteristics of a good programming language -1
4. Completeness
• A language rich with libraries is preferred
5. Expressiveness
• Expressiveness is the ability to reshape the language until you can express your
program naturally.
• Lisp and Scheme let you implement a new internal language for describing
your program concisely.
• Smalltalk, Ruby and Haskell have basic building blocks and lightweight syntax
that makes it easy to define new language constructs for your particular
problem.
• This property is very important because code is to be read by humans
first and then computers
1. Readability: Should allow programs to be written in ways that
2. Portability: Should be able to develop portable software.
3. Generality: Writing of a wide variety of programs, thus relieving the programmer of the need
to become expert in many diverse languages.
4. Brevity: Ability to implement the algorithm with less amount of code.
5. Error checking:. Error checking both at compile-time and at run-time.
6. Familiar notation: A language should have familiar notation, so it can be understood by most
of the programmers.
7. Quick translation: It should admit quick translation.
8. Efficiency: It should permit the generation of efficient object code.
9. Modularity: It is desirable that programs can be developed in the language as a collection of
separately compiled modules, with appropriate mechanisms for ensuring self-consistency
between these modules.
10 Widely available: Language should be widely available and it should be possible to provide
translators for all the major machines and for all the major operating systems.
A good programming language -2
C Programming
C Programming
Character set - is set of characters used to form constants, variables and expressions
Categories of C character set
A. Letters
B. Digits
C. Special Characters
D. White-spaces
•Letters - A…Z , a…..z
• Digits - 0….9
• White spaces
• blank
• horizontal tab
•Carriage return
• New line
• Form feed
C Programming
Special Characters
, Comma & Ampersand
. Period ^ Caret
; Semicolon * asterisk
: colon - Minus
? Question mark + Plus
‘ Apostrophe < Opening angle bracket
! Exclamation > Closing angle bracket
| Vertical bar ( left parenthesis
/ Slash ) Right parenthesis
“ Quotation mark  Back slash
~ Tilde [ Left bracket
_ Underscore ] Right bracket
$ Dollar sign { Left brace
% Percentage sign } Right brace
# Number sign
C Tokens
• C language statements are made of tokens
•Tokens are smallest recognizable units of language
• Any C language statement consists of following six types of tokens
1. Keywords - language specific words with special meaning - float , if , int , while ,
2. Identifiers - user defined names of variables , functions etc - main , age , etc …
3. Constant or literals - 12, 57, 38.69, 99.6756,
4. String - ‘A’, ‘ Vishwakarma’
5. Operators - + , - , * , = , ++ , --
6. Special symbol - , [] , {} , %
Example - identify tokens
void main(void)
{
int age = 28 ; clrscr(); printf(“My age is %d”, age);
}
auto double int struct
break else long switch
case enum register typedef
char extern return union
const float short unsigned
continue for signed void
default goto sizeof volatile
do if static while
1. Keywords
•All keywords have fixed meanings which can not be changed
•Key words are basic building blocks of a statement
2. Identifiers
• These are names of variables and functions or arrays which are user defined
• Contain sequence of letters, digits
Rules of naming identifiers
1. First character must be alphabet
2. Must have letters , digits and underscore only
3. Length can be 31 maximum
4. Cannot use a keyword
5. Must not have any white spaces
3. Integer Constants
• These are fixed values that do not change
• Integer constants - sequence of digits
• Decimal integers - will have 0 to 9 with optional + or -
• 123,567, -45, 0 , 653456
• Octal integers - will have 0 to 7 with optional + or - and with leading zero
• 037 , 0 , 0435 , 0551
• Hexadecimal integers - will have 0 to A with optional + or - and with leading 0x
• 0x2 , 0x , 0xBCD , 0x3FFF
•Largest value that can be stored is machine dependant
• 16 bit machine can store can store maximum integer = 32767 = 215 - 1
• 32 bit machine can store can store maximum integer = 2147483647 = 231 - 1
• Integer constant can be unsigned or signed or long
• 56789U ( unsigned integer )
•89776788UL ( unsigned long integer )
•786756L ( long integer )
http://www.tutorialspoint.com/ansi_c/c_using_constants.htm
•
3. Floating point or real Constants
• These are fixed values that do not change
• Real or floating point constants - numbers with fractional parts
• 0.0083 , -0.75 , +247.45 , 215. . .95 , -.71 , +.5 (omit digit before after .)
• Scientific notation of real numbers
• mantissa e exponent
• mantissa can be real number but exponent is always an + or - integer
• exponent causes decimal point to float so called as floating point form
• 0.65e4 12e-2 , 1.5e+5 3.18E3 - 1.2E-1
• This notation is used to represent very large or very small numbers
• 750000000000  7.5E9
• -0.0000000000000000000000000368  -3.68E-26
3. Constants - Find naming errors
Number Valid ? Remarks
698345L
25,000
+5.0E3
3.5e-5
7.1e4
-4.5e-2
1.5E+2.5
$255
0X7B
3. Constants - Find naming errors
Number Valid ? Remarks
698345L Yes Long integer
25,000 No Comma not allowed
+5.0E3 Yes
3.5e-5 Yes
7.1e 4 No No white space permitted
-4.5e-2 Yes
1.5E+2.5 No Exponent must be integer
$255 No $ not permitted
0X7B Yes Hexadecimal integer
3. Single Character constants
• contains single character enclosed in single quotes
• ‘5’ ‘X’ ‘;’ ‘ ‘ ‘’ ‘Z’
• note 5 is integer but ‘5’ is character
• each character constant is stored internally with an ASCII code
printf(“%d”, ‘a’)  would display 97
printf(“%d”, ‘108’)  would display l
4. String constants
• contains sequence of characters enclosed in double quotes
• “Hello” , “1987” , “5+3-2=?”
• it may have letters , digits and special characters
• string constant “A” or “8” does not have an integer value
• ‘5’ and “5” are different
• C compiler automatically store character ‘0’ at the end of every defined
string constant
4. Escape Sequences - Single Character Constant
‘a’ bell
‘b’ back space
‘f’ form feed
‘n’ New line
‘t’ Horizontal tab
‘v’ Vertical tab
‘’’ Single quotes
‘’ Double quotes
‘0’ null
Special character constants - Escape sequences
Constants
Numeric Character
Integer Real
Single
character
String
Variables
• Variable is a data name used to store a value that can change
• variable can take different values during program execution
• a variable should have a meaningful name
• average , sex , age , total , counter , lineno etc
Name Valid ? Remark
First_tag
char
Price$
group one
average _number
int_type
Variables
Name Valid ? Remark
First_tag Valid
char Not Valid char is keyword
Price$ Not Valid Dollar illegal
group one Not Valid Blank space
average _number Valid
int_type Valid
Data Types
• Variety of data types allow programmer to select type appropriate to the needs
and the processor
• There are three 3 classes of data types in ANSI C
• Primary or primitive data types - int , char , float , void
• Derived data types - arrays , structures , pointers , functions
• User defined data types - typedef , enum
Primitive data types
Data type Size Range of values
Char 1 byte -128 to 127
Int 2 bytes - 32768 to 32767
Float 4 bytes 3.4e-38 to 3.e+e38
Double 8 Bytes 1.7e-308 to 1.7e+308
Data Types
•Integer type
• whole numbers
• range supported by a specific machine
• occupy one word )
• word size depends on processor - 16 or 32
• for 16 bit processor - integer values are -215 to 215-1
• default is signed integer which stores sign of number in last bit
• short int - half the word size
• int - - word size
• long int - double the word size
• unsigned integers use all bits for magnitude
• long and unsigned can increase range of values required to be stored
Type Size Type Size
char 8 long int 32
int or signed int 16 unsigned long int 32
unsigned int 16 float 32
short int 8 double 64
unsigned short int 8 long double 80
long int
int
short int
Data Types
• Floating point type
• Real numbers stored in 32 bit format
• keyword - float , double used when higher accuracy required
• double uses 64 bits storage space - known as double precision number
• floating point describes a method of representing an approximation of a real number in a
way that can support a wide range of values.
• It has fixed number of significant digits (the mantissa) and scaled using an exponent
• Significant digits × baseexponent
•
• Void Type
• void type has no values
• used to specify function type
• function is void if it does not return any value to calling function
• it can also represent generic type
long double
double
float
Data Types
• Character types
• Single character can be defined as character type data
• They are stored in 8 bits (one byte)
• unsingned char  0 to 255 values
• signed char  -127 to 127
Variable declarations
• tells compiler what the variable name is
• tells compiler what type of data it will store
• declaration must be done before they are used in program
<data type> <variable 1>, *<variable2> , ….+
Primary type declaration
int count ;
• int sum, total;
• char choice;
• float ratio,x,y;
• short int row;
• long int amount ;
• double deviation ;
• char c;
• unsigned n; ( short , long , unsigned without data type is treated as integer)
• qualifiers  signed , unsigned , short , long
•
Constants
Integer constants
+111 int
-222 int
45678U unsigned int
-56789L long int
987654UL unsigned long t
Real constants
0. double
.0 double
12.0 double
1.234 double
-1.2f float
1.234567L long double
Defining symbolic constants
• defining macro definitions
• use #define which is a preprocessor directive
• does not end with a semicolon
• placed before main
• used to define symbolic constants like pi etc
• #define pi 3.142
• #define name Yogesh
• #define VIIT Vishwakarma Institute of information technology
• # define STRENGTH 100
• # define PASS_MARK 50
• # define ASCII_A 65
• # define ASCII_Z 95
Defining symbolic constants
• #define X=2.5
• # define MAX 10 - white space
• #define N 25;
• #define N 5, M 10 - multiple not allowed
• #Define ARRAY 11
Comments
Comments are used for documentation purpose
Statements enclosed in /* and */ are not compiled
Multiple lines can be commented by puttiong /* at start and */ at the
end.
/* Include function declarations */
#include<stdio.h>
#include<conio.h>
Void main(void)
{
/* Variables */
int x ; char y; int num[15];
printf(“nEnter age : “);
scanf(”%d”,&x);
}
Operators and expressions
• Arithmetic Operators
• + addition or nary plus
• - subtraction or us nary minus
• * multiplication
• / division
• % Modulo division
• Integer division truncates fractional part
• % can not be used on floating point numbers
• C does not have a operator for exponent
• During modulo division sign of first operand is sign of the result
• -14 % 3 = -2
• -14 % -3 = -2
• 14 % -3 = 2
Operators and expressions
• Relational Operators
• < , <= , > , >= , == ! =
• if expression is zero it is false else true.
• if expression1 operator expression2 - first expression is evaluated and then
the results are compared
• Arithmetic operator have higher priority over relational operators
• > complement of <=
• < complement of >=
• == complement of !=
• !(x<y)  x<=y
• !(x==y)  x!=y
• !(x<=y)  x > y
Operators and expressions
• Logical Operators - combining multiple conditions
• && - logical AND
• || - logical OR
• ! - logical NOT
if (age > 55 && salary < 1000)
if ( number < 0 || number > 100)
Precedence
Highest !
> >= < <=
== !=
&&
Lowest ||
Operators and expressions
• Assignment Operator
• Used to assign result of an expression =
• Shorthand assignment += , -=
• x+=y+1  x=x+(y+1)
• x+=3  x=x+3
• a=a+1  a+=1
• a=a-1 -> a-=1
• a=a*(n+1)  a*=(n+1)
• a = a / (n+1)  a/= (n+1)
• a=a%b  a%=b
Operators and expressions
• Increment and decrement Operator
• ++ m 0r m++ and --m or m—
• prefix ++ or -- increments or decrements variable & then uses in expression
• postfix ++ or -- uses current value in expression and then increments or
decrements variable
• eg. a=3 ; b=5 ; c=10 ; z=0
• z=a++;
• b=--c;
• a=z--; what are values in a, b, c and z at the end
• y=a++ -b-- +--c ;
• Can also be used in subscripted variables e.g. num[i++]=10 ;
• Rules :
•
Operators and expressions
• Conditional Operator
• Ternary operator
• exp1 ? exp2 : exp3 - exp1 is conditional statement
• if exp1 is non zero or true exp2 is evaluated else exp3 evaluated
a=10
b=15
x= (a>b) ? a: b;
if ( a>b)
x=a;
else
x=b;
Operators and expressions
• Precedence of operators
• An expression without parenthesis will be evaluated left to right using
rules of precedence of operators
• Two levels of priority in arithmetic operators
• High - * / %
• Low - + -
• first pass  high priority operators are applied
• second pass  low priority operators are applied
• x=a-b/3+c*2-1 a=9 b=12 c=3
• First pass  9-(12/3)+(3*2)-1 and a-4+6-1
• Second pass  5+6-1 , 11-1 , 10
•E.g. 9-12/(3+3)*(2-1)
• 1st pass  9-12/6*(2-1) and 9-12/6*1
• 2nd pass  9-2*1 and 9-2
• 3rd pass  7
Operators and expressions
• Precedence of operators
• parenthesis may be nested --- in such cases evaluation of the expression
will proceed outward from the innermost set of parenthesis.
• 9-(12/(3+3) * 2) -1 = ?
• 9-((12/3)+3 *2)-1 = ?
• Rules
• First parenthesized sub-expressions from left to right are evaluated
• If nested parenthesis evaluation begins from innermost sub-expression
• Precedence rule of operators is then applied
• Associative rule applied if two operators of same level appear
• Arithmetic expressions are evaluated form left to right using rules of
precedence
• Expression within parenthesis assume highest priority
Operators and expressions
int a
a= 5 <=8 && 6!=5 ;
printf(“%d”, a);
getch();
Answers =1
some computational problems
(A) Division of frictional numbers
a= 1.0 / 3.0;
b= a * 3.0 ; What is value of b ?
(B) Divide by zero
Operators and expressions
(B) Overflow or underflow - operand should be of correct type and size
otherwise there will round-off errors introduced
float sum, n, term;
int count = 1;
sum=0 ;
printf (“Enter value of n n”);
scanf(“%f”,&n);
term= 1.0/n;
while ( count <=n)
{
sum= sum + term;
count++;
}
printf(“ Sum = %fn”, sum);
}
Output
Enter value of n
99
Sum= 1.000001
Enter value of n
143
sum= 0.999999
String Handling
#include<stdio.h>
#include<conio.h>
void main(void)
{
/* Input a string */
char string[25];
clrscr();
printf("Input a string : ");
scanf("%s",string);
String Handling
/* Find length of string */
i=0;
slen=0;
while(string[i]!='0')
{
slen++;
i++;
}
printf("nString length : %d",slen);
String Handling
/* Dislay string in reverse order */
i=slen;
printf("nReverse string : ");
while(i>=0)
{
printf("%c",string[i]);
i--;
}
String Handling
/* Find number of vowels in string */
i=slen;
while(i>=0)
{
switch(string[i])
{
case 'A' :
case 'a' :
case 'E' :
case 'e' :
case 'I' :
case 'i' :
case 'O' :
case 'o' :
case 'U' :
case 'u' : Nvowels++;
break;
}
i--;
}
printf("nNumber of vowels : %d",Nvowels);
String Handling
/* Find number of 'a' or 'A' in string */
Na=0;
for(i=0; i<slen; i++)
{
if(string[i] =='a' || string[i] == 'A')
Na++;
}
printf("nTotal number of charater 'a' or 'A' : %d ",Na);
String Handling
/* Check is string is palindrome */
i=0;
j=slen-1;
while(string[i]==string[j])
{
i++;
j--;
if(i>j)
break;
}
if(i>=j)
printf("nString is palindrome");
else
printf("nString is not a palindrome");
getch();
String Handling
String Handling
Extra
3. Constants - Find naming errors
• Binary code
• Assembly language  Assembles
• Low-level programming languages (Like C, C++, B, D, fortain, objc, simula...)
•High-level languages (Like C++.NET, erlang) -> very high/goal level programming languages
• Low level interpreted languages (like Java, C#...) ->
• Mid level (Python, Ruby) ->
•high level (no bytecode) interpreted languages (Bash, PHP, Lua) -> "Structure interpeted"
• A high-level programming language that is interpreted by another program at runtime rather than
compiled by the computer's processor as other programming languages (such as C and C++)
•Programming language where scripts / programs written for a special runtime environment that will
interpret/automate tasks which could be executed one-by-one by a human
• For instance, one could put a series of editing commands in a file, and tell an editor to run that "script" as if
those commands had been typed interactively.
• Scripts are tasks written for runtime environment and interpreted at runtime in a batch
• Many programs can be together pipelined in script -- eg. Shell script in Linux
• The primary focus isn't primarily building your own apps so much as getting an existing app to act the way
you want,
• Scripting is used to configure web pages within browser , shells of OS
•Typically, a scripting language is characterized by the following properties
• Ease of use. - very fast to learn has simple syntax and semantics.
• OS facilities - Scripting is usually aimed at desktops, limiting the portability needs of the pre-built libraries.
• Interpreted from source code - to give the fastest turnaround from script to execution.
• Relatively loose structure. It would be difficult to use Java as a scripting language due to the rules about
which classes exist in which files - contrast to Python, where it's possible to simply define some functions in
a file.
• An interpreter or a virtual machine is required
Scripting Language
•Source code is present at run time in production system and compiled into native object code.
• Use of an interpreter or Virtual Machine is generally required; though the OS may arrange for the
appropriate interpreter to be invoked automatically.
•Explicit compilation or linking phases are not needed
•Variables, functions, and methods typically do not require type declarations.
.
•Very powerful built-in types - typically a dictionary, a set, a literal type that can act as either
numeric or strings.
•The ability to generate, load, and interpret source code at run time through an eval function. (Perl,
Python, Tcl, JavaScript, shell scripts, REXX, APL;
•Interface to the underlying operating system, in order to run other programs and communicate with
them.
•Rich I/O capabilities, including pipes, network sockets, file I/O, and file system operations.
Properties of a scripting language
Characteristics of a good programming language -1
• Vocabulary should resemble English (or some other human language).
• Programs should consist of instructions- tedious declarations should be kept to a minimum.
• The language , its classes or functions in libraries should be fully documented.
•There should be no need to manipulate pointers explicitly no means of doing so. They should
be managed by the language and not by the programmer.
•The language should provide arrays of unlimited size: there should be no need to declare array
bounds.
•Sorting facilities should be included as standard; we shouldn't have to write our own sort
routines.
•The language should provide full facilities for handling a graphical user interface. These
• Should be able to keep one project separate from another and projects should be separated
from libraries supplied with the language.

Contenu connexe

Tendances

Introduction to course
Introduction to courseIntroduction to course
Introduction to coursenikit meshram
 
Compiler Design Basics
Compiler Design BasicsCompiler Design Basics
Compiler Design BasicsAkhil Kaushik
 
Compiler design Introduction
Compiler design IntroductionCompiler design Introduction
Compiler design IntroductionAman Sharma
 
Presentation on computer language
Presentation on computer languagePresentation on computer language
Presentation on computer languageSwarnima Tiwari
 
Introduction to Compilers
Introduction to CompilersIntroduction to Compilers
Introduction to CompilersAkhil Kaushik
 
System Programming Unit III
System Programming Unit IIISystem Programming Unit III
System Programming Unit IIIManoj Patil
 
High Level Language (HLL)
High Level Language (HLL)High Level Language (HLL)
High Level Language (HLL)Maliha Jahan
 
classification of computer language
classification of computer languageclassification of computer language
classification of computer languageBinamraRegmi
 
Introduction to Programming Languages
Introduction to Programming LanguagesIntroduction to Programming Languages
Introduction to Programming Languageseducationfront
 
introduction to Programming Lecture 1
introduction to Programming Lecture 1introduction to Programming Lecture 1
introduction to Programming Lecture 1yarafghani
 
Ch1 language design issue
Ch1 language design issueCh1 language design issue
Ch1 language design issueJigisha Pandya
 
Syntax directed-translation
Syntax directed-translationSyntax directed-translation
Syntax directed-translationJunaid Lodhi
 
Programming fundamentals presentation
Programming fundamentals presentationProgramming fundamentals presentation
Programming fundamentals presentationHafsaRao1
 
Compiler Design
Compiler DesignCompiler Design
Compiler DesignMir Majid
 
Principles of programming languages. Detail notes
Principles of programming languages. Detail notesPrinciples of programming languages. Detail notes
Principles of programming languages. Detail notesVIKAS SINGH BHADOURIA
 

Tendances (19)

Introduction to course
Introduction to courseIntroduction to course
Introduction to course
 
Compiler Design Basics
Compiler Design BasicsCompiler Design Basics
Compiler Design Basics
 
Introduction to programming languages
Introduction to programming languagesIntroduction to programming languages
Introduction to programming languages
 
Compiler design Introduction
Compiler design IntroductionCompiler design Introduction
Compiler design Introduction
 
Presentation on computer language
Presentation on computer languagePresentation on computer language
Presentation on computer language
 
Introduction to Compilers
Introduction to CompilersIntroduction to Compilers
Introduction to Compilers
 
System Programming Unit III
System Programming Unit IIISystem Programming Unit III
System Programming Unit III
 
High Level Language (HLL)
High Level Language (HLL)High Level Language (HLL)
High Level Language (HLL)
 
classification of computer language
classification of computer languageclassification of computer language
classification of computer language
 
Introduction to Programming Languages
Introduction to Programming LanguagesIntroduction to Programming Languages
Introduction to Programming Languages
 
introduction to Programming Lecture 1
introduction to Programming Lecture 1introduction to Programming Lecture 1
introduction to Programming Lecture 1
 
Ch1 language design issue
Ch1 language design issueCh1 language design issue
Ch1 language design issue
 
History of languages'
History of languages'History of languages'
History of languages'
 
Syntax directed-translation
Syntax directed-translationSyntax directed-translation
Syntax directed-translation
 
Computer Language
Computer LanguageComputer Language
Computer Language
 
Programming fundamentals presentation
Programming fundamentals presentationProgramming fundamentals presentation
Programming fundamentals presentation
 
Computer language
Computer languageComputer language
Computer language
 
Compiler Design
Compiler DesignCompiler Design
Compiler Design
 
Principles of programming languages. Detail notes
Principles of programming languages. Detail notesPrinciples of programming languages. Detail notes
Principles of programming languages. Detail notes
 

En vedette

Principle Of Emptiness
Principle Of EmptinessPrinciple Of Emptiness
Principle Of Emptinesschiya85
 
Genre presentation
Genre presentationGenre presentation
Genre presentationamylouiseee
 
eArhivar - Docs 4 ever SES
eArhivar - Docs 4 ever SESeArhivar - Docs 4 ever SES
eArhivar - Docs 4 ever SESAdrian Dan Pop
 
Legal committee-topic-area-b rotaract global model un 2015
Legal committee-topic-area-b  rotaract global model un 2015Legal committee-topic-area-b  rotaract global model un 2015
Legal committee-topic-area-b rotaract global model un 2015Adrian Dan Pop
 
Study guide legal committee-topic-area-a rotaract global mun 2015
Study guide legal committee-topic-area-a  rotaract global mun 2015Study guide legal committee-topic-area-a  rotaract global mun 2015
Study guide legal committee-topic-area-a rotaract global mun 2015Adrian Dan Pop
 

En vedette (8)

Principle Of Emptiness
Principle Of EmptinessPrinciple Of Emptiness
Principle Of Emptiness
 
THE VAMPIRE TALE
THE VAMPIRE TALETHE VAMPIRE TALE
THE VAMPIRE TALE
 
Storyboard
StoryboardStoryboard
Storyboard
 
Storyboard
StoryboardStoryboard
Storyboard
 
Genre presentation
Genre presentationGenre presentation
Genre presentation
 
eArhivar - Docs 4 ever SES
eArhivar - Docs 4 ever SESeArhivar - Docs 4 ever SES
eArhivar - Docs 4 ever SES
 
Legal committee-topic-area-b rotaract global model un 2015
Legal committee-topic-area-b  rotaract global model un 2015Legal committee-topic-area-b  rotaract global model un 2015
Legal committee-topic-area-b rotaract global model un 2015
 
Study guide legal committee-topic-area-a rotaract global mun 2015
Study guide legal committee-topic-area-a  rotaract global mun 2015Study guide legal committee-topic-area-a  rotaract global mun 2015
Study guide legal committee-topic-area-a rotaract global mun 2015
 

Similaire à FPL - Part 1 (Sem - I 2013 )

Similaire à FPL - Part 1 (Sem - I 2013 ) (20)

Unit ii
Unit   iiUnit   ii
Unit ii
 
C LANGUAGE UNIT-1 PREPARED BY M V BRAHMANANDA REDDY
C LANGUAGE UNIT-1 PREPARED BY M V BRAHMANANDA REDDYC LANGUAGE UNIT-1 PREPARED BY M V BRAHMANANDA REDDY
C LANGUAGE UNIT-1 PREPARED BY M V BRAHMANANDA REDDY
 
C languaGE UNIT-1
C languaGE UNIT-1C languaGE UNIT-1
C languaGE UNIT-1
 
C language unit-1
C language unit-1C language unit-1
C language unit-1
 
Compilers.pptx
Compilers.pptxCompilers.pptx
Compilers.pptx
 
Computer Programming In C.pptx
Computer Programming In C.pptxComputer Programming In C.pptx
Computer Programming In C.pptx
 
c++
 c++  c++
c++
 
Introduction_to_Programming.pptx
Introduction_to_Programming.pptxIntroduction_to_Programming.pptx
Introduction_to_Programming.pptx
 
FINAL.ppt
FINAL.pptFINAL.ppt
FINAL.ppt
 
C_Programming_Notes_ICE
C_Programming_Notes_ICEC_Programming_Notes_ICE
C_Programming_Notes_ICE
 
C for Engineers
C for EngineersC for Engineers
C for Engineers
 
introduction to C programming (C)
introduction to C programming (C)introduction to C programming (C)
introduction to C programming (C)
 
week 2 - INTRO TO PROGRAMMING.pptx
week 2 - INTRO TO PROGRAMMING.pptxweek 2 - INTRO TO PROGRAMMING.pptx
week 2 - INTRO TO PROGRAMMING.pptx
 
Python-unit -I.pptx
Python-unit -I.pptxPython-unit -I.pptx
Python-unit -I.pptx
 
X-CS-8.0 Programming in C Language 2022-2023.pdf
X-CS-8.0 Programming in C Language 2022-2023.pdfX-CS-8.0 Programming in C Language 2022-2023.pdf
X-CS-8.0 Programming in C Language 2022-2023.pdf
 
Design Like a Pro: Scripting Best Practices
Design Like a Pro: Scripting Best PracticesDesign Like a Pro: Scripting Best Practices
Design Like a Pro: Scripting Best Practices
 
Basic terms used in microprocessor
Basic terms used in microprocessorBasic terms used in microprocessor
Basic terms used in microprocessor
 
Lecture 2
Lecture 2Lecture 2
Lecture 2
 
Design Like a Pro: Scripting Best Practices
Design Like a Pro: Scripting Best PracticesDesign Like a Pro: Scripting Best Practices
Design Like a Pro: Scripting Best Practices
 
Embedded programming Embedded programming (1).pptx
Embedded programming Embedded programming (1).pptxEmbedded programming Embedded programming (1).pptx
Embedded programming Embedded programming (1).pptx
 

Dernier

Merck Moving Beyond Passwords: FIDO Paris Seminar.pptx
Merck Moving Beyond Passwords: FIDO Paris Seminar.pptxMerck Moving Beyond Passwords: FIDO Paris Seminar.pptx
Merck Moving Beyond Passwords: FIDO Paris Seminar.pptxLoriGlavin3
 
Varsha Sewlal- Cyber Attacks on Critical Critical Infrastructure
Varsha Sewlal- Cyber Attacks on Critical Critical InfrastructureVarsha Sewlal- Cyber Attacks on Critical Critical Infrastructure
Varsha Sewlal- Cyber Attacks on Critical Critical Infrastructureitnewsafrica
 
Arizona Broadband Policy Past, Present, and Future Presentation 3/25/24
Arizona Broadband Policy Past, Present, and Future Presentation 3/25/24Arizona Broadband Policy Past, Present, and Future Presentation 3/25/24
Arizona Broadband Policy Past, Present, and Future Presentation 3/25/24Mark Goldstein
 
Modern Roaming for Notes and Nomad – Cheaper Faster Better Stronger
Modern Roaming for Notes and Nomad – Cheaper Faster Better StrongerModern Roaming for Notes and Nomad – Cheaper Faster Better Stronger
Modern Roaming for Notes and Nomad – Cheaper Faster Better Strongerpanagenda
 
Transcript: New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024Transcript: New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024BookNet Canada
 
Time Series Foundation Models - current state and future directions
Time Series Foundation Models - current state and future directionsTime Series Foundation Models - current state and future directions
Time Series Foundation Models - current state and future directionsNathaniel Shimoni
 
How AI, OpenAI, and ChatGPT impact business and software.
How AI, OpenAI, and ChatGPT impact business and software.How AI, OpenAI, and ChatGPT impact business and software.
How AI, OpenAI, and ChatGPT impact business and software.Curtis Poe
 
Moving Beyond Passwords: FIDO Paris Seminar.pdf
Moving Beyond Passwords: FIDO Paris Seminar.pdfMoving Beyond Passwords: FIDO Paris Seminar.pdf
Moving Beyond Passwords: FIDO Paris Seminar.pdfLoriGlavin3
 
React Native vs Ionic - The Best Mobile App Framework
React Native vs Ionic - The Best Mobile App FrameworkReact Native vs Ionic - The Best Mobile App Framework
React Native vs Ionic - The Best Mobile App FrameworkPixlogix Infotech
 
Long journey of Ruby standard library at RubyConf AU 2024
Long journey of Ruby standard library at RubyConf AU 2024Long journey of Ruby standard library at RubyConf AU 2024
Long journey of Ruby standard library at RubyConf AU 2024Hiroshi SHIBATA
 
Generative Artificial Intelligence: How generative AI works.pdf
Generative Artificial Intelligence: How generative AI works.pdfGenerative Artificial Intelligence: How generative AI works.pdf
Generative Artificial Intelligence: How generative AI works.pdfIngrid Airi González
 
Bridging Between CAD & GIS: 6 Ways to Automate Your Data Integration
Bridging Between CAD & GIS:  6 Ways to Automate Your Data IntegrationBridging Between CAD & GIS:  6 Ways to Automate Your Data Integration
Bridging Between CAD & GIS: 6 Ways to Automate Your Data Integrationmarketing932765
 
TrustArc Webinar - How to Build Consumer Trust Through Data Privacy
TrustArc Webinar - How to Build Consumer Trust Through Data PrivacyTrustArc Webinar - How to Build Consumer Trust Through Data Privacy
TrustArc Webinar - How to Build Consumer Trust Through Data PrivacyTrustArc
 
The Ultimate Guide to Choosing WordPress Pros and Cons
The Ultimate Guide to Choosing WordPress Pros and ConsThe Ultimate Guide to Choosing WordPress Pros and Cons
The Ultimate Guide to Choosing WordPress Pros and ConsPixlogix Infotech
 
TeamStation AI System Report LATAM IT Salaries 2024
TeamStation AI System Report LATAM IT Salaries 2024TeamStation AI System Report LATAM IT Salaries 2024
TeamStation AI System Report LATAM IT Salaries 2024Lonnie McRorey
 
The Fit for Passkeys for Employee and Consumer Sign-ins: FIDO Paris Seminar.pptx
The Fit for Passkeys for Employee and Consumer Sign-ins: FIDO Paris Seminar.pptxThe Fit for Passkeys for Employee and Consumer Sign-ins: FIDO Paris Seminar.pptx
The Fit for Passkeys for Employee and Consumer Sign-ins: FIDO Paris Seminar.pptxLoriGlavin3
 
Decarbonising Buildings: Making a net-zero built environment a reality
Decarbonising Buildings: Making a net-zero built environment a realityDecarbonising Buildings: Making a net-zero built environment a reality
Decarbonising Buildings: Making a net-zero built environment a realityIES VE
 
Generative AI - Gitex v1Generative AI - Gitex v1.pptx
Generative AI - Gitex v1Generative AI - Gitex v1.pptxGenerative AI - Gitex v1Generative AI - Gitex v1.pptx
Generative AI - Gitex v1Generative AI - Gitex v1.pptxfnnc6jmgwh
 
Scale your database traffic with Read & Write split using MySQL Router
Scale your database traffic with Read & Write split using MySQL RouterScale your database traffic with Read & Write split using MySQL Router
Scale your database traffic with Read & Write split using MySQL RouterMydbops
 
Connecting the Dots for Information Discovery.pdf
Connecting the Dots for Information Discovery.pdfConnecting the Dots for Information Discovery.pdf
Connecting the Dots for Information Discovery.pdfNeo4j
 

Dernier (20)

Merck Moving Beyond Passwords: FIDO Paris Seminar.pptx
Merck Moving Beyond Passwords: FIDO Paris Seminar.pptxMerck Moving Beyond Passwords: FIDO Paris Seminar.pptx
Merck Moving Beyond Passwords: FIDO Paris Seminar.pptx
 
Varsha Sewlal- Cyber Attacks on Critical Critical Infrastructure
Varsha Sewlal- Cyber Attacks on Critical Critical InfrastructureVarsha Sewlal- Cyber Attacks on Critical Critical Infrastructure
Varsha Sewlal- Cyber Attacks on Critical Critical Infrastructure
 
Arizona Broadband Policy Past, Present, and Future Presentation 3/25/24
Arizona Broadband Policy Past, Present, and Future Presentation 3/25/24Arizona Broadband Policy Past, Present, and Future Presentation 3/25/24
Arizona Broadband Policy Past, Present, and Future Presentation 3/25/24
 
Modern Roaming for Notes and Nomad – Cheaper Faster Better Stronger
Modern Roaming for Notes and Nomad – Cheaper Faster Better StrongerModern Roaming for Notes and Nomad – Cheaper Faster Better Stronger
Modern Roaming for Notes and Nomad – Cheaper Faster Better Stronger
 
Transcript: New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024Transcript: New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024
 
Time Series Foundation Models - current state and future directions
Time Series Foundation Models - current state and future directionsTime Series Foundation Models - current state and future directions
Time Series Foundation Models - current state and future directions
 
How AI, OpenAI, and ChatGPT impact business and software.
How AI, OpenAI, and ChatGPT impact business and software.How AI, OpenAI, and ChatGPT impact business and software.
How AI, OpenAI, and ChatGPT impact business and software.
 
Moving Beyond Passwords: FIDO Paris Seminar.pdf
Moving Beyond Passwords: FIDO Paris Seminar.pdfMoving Beyond Passwords: FIDO Paris Seminar.pdf
Moving Beyond Passwords: FIDO Paris Seminar.pdf
 
React Native vs Ionic - The Best Mobile App Framework
React Native vs Ionic - The Best Mobile App FrameworkReact Native vs Ionic - The Best Mobile App Framework
React Native vs Ionic - The Best Mobile App Framework
 
Long journey of Ruby standard library at RubyConf AU 2024
Long journey of Ruby standard library at RubyConf AU 2024Long journey of Ruby standard library at RubyConf AU 2024
Long journey of Ruby standard library at RubyConf AU 2024
 
Generative Artificial Intelligence: How generative AI works.pdf
Generative Artificial Intelligence: How generative AI works.pdfGenerative Artificial Intelligence: How generative AI works.pdf
Generative Artificial Intelligence: How generative AI works.pdf
 
Bridging Between CAD & GIS: 6 Ways to Automate Your Data Integration
Bridging Between CAD & GIS:  6 Ways to Automate Your Data IntegrationBridging Between CAD & GIS:  6 Ways to Automate Your Data Integration
Bridging Between CAD & GIS: 6 Ways to Automate Your Data Integration
 
TrustArc Webinar - How to Build Consumer Trust Through Data Privacy
TrustArc Webinar - How to Build Consumer Trust Through Data PrivacyTrustArc Webinar - How to Build Consumer Trust Through Data Privacy
TrustArc Webinar - How to Build Consumer Trust Through Data Privacy
 
The Ultimate Guide to Choosing WordPress Pros and Cons
The Ultimate Guide to Choosing WordPress Pros and ConsThe Ultimate Guide to Choosing WordPress Pros and Cons
The Ultimate Guide to Choosing WordPress Pros and Cons
 
TeamStation AI System Report LATAM IT Salaries 2024
TeamStation AI System Report LATAM IT Salaries 2024TeamStation AI System Report LATAM IT Salaries 2024
TeamStation AI System Report LATAM IT Salaries 2024
 
The Fit for Passkeys for Employee and Consumer Sign-ins: FIDO Paris Seminar.pptx
The Fit for Passkeys for Employee and Consumer Sign-ins: FIDO Paris Seminar.pptxThe Fit for Passkeys for Employee and Consumer Sign-ins: FIDO Paris Seminar.pptx
The Fit for Passkeys for Employee and Consumer Sign-ins: FIDO Paris Seminar.pptx
 
Decarbonising Buildings: Making a net-zero built environment a reality
Decarbonising Buildings: Making a net-zero built environment a realityDecarbonising Buildings: Making a net-zero built environment a reality
Decarbonising Buildings: Making a net-zero built environment a reality
 
Generative AI - Gitex v1Generative AI - Gitex v1.pptx
Generative AI - Gitex v1Generative AI - Gitex v1.pptxGenerative AI - Gitex v1Generative AI - Gitex v1.pptx
Generative AI - Gitex v1Generative AI - Gitex v1.pptx
 
Scale your database traffic with Read & Write split using MySQL Router
Scale your database traffic with Read & Write split using MySQL RouterScale your database traffic with Read & Write split using MySQL Router
Scale your database traffic with Read & Write split using MySQL Router
 
Connecting the Dots for Information Discovery.pdf
Connecting the Dots for Information Discovery.pdfConnecting the Dots for Information Discovery.pdf
Connecting the Dots for Information Discovery.pdf
 

FPL - Part 1 (Sem - I 2013 )

  • 1. Computer (data processor) is a machine which executes the instructions (given by the user) to processes the data (also given by the user) with a very high speed . Computer (Data Processor) Instructions / Program Data (Raw input) Information (Processed Output) How to process ? What to process ? Program - A sequence of logically connected instructions coded in a particular language to perform a specific task Data : The material on which the program instructions operate Data processing - capturing input data, manipulating data & representing output information Computer
  • 2. Characteristics of computer •Automatic - works without human intervention once program and data is fed. •Speed - High speed processor - billion( 109) or trillion(1012) instructions per seconds (BIPS) •Accuracy - produces continues accurate results (errors in data / program  garbage ) •Diligence - free from monotony , tiredness and lack of concentration •Versatility - capable of performing any type of task depending on the program given •Power of remembering - Can store/retain huge amount of program, data and information in a secondary memory and can recall it whenever required • No IQ - Has no intelligence of its own - can not take its own decision • NO feelings - Computers are devoid of emotions - judgments only made based on instructions •Evolution of computer generations  1,2,3,4,5 (Home Work)
  • 3. Input Device Output Device Processor Memory (01001110010101) Instructions +Data Information (1) Inputting (3) Processing - arithmetic & logical operation) (5) outputting Keyboard Mouse Microphone Touch Screen Camera Scanner Screen Printer Speaker Organization (2) storing (4) retrieving
  • 4. Input Device Output Device Processor Primary Memory fast but small in capacity Organization Secondary Memory slow but large in capacity Book Shelf processing save load working desk
  • 5. Secondary memory Primary Memory Arithmetic Logic Unit (ALU) Control Unit (CU) Input Unit Output Unit CENTRAL PROCESING UNIT (CPU) STORAGE UNIT (SU) encoding using input interfaces decoding using output interfaces Program Data Program Data calculation and comparisons coordinates all components
  • 6. Storage Unit Characteristic Primary / Main Memory Secondary / Auxiliary Usage Essential for a CPU and processing Working memory Not essential for CPU and processing Non-working memory Location Mother Board or main circuitry Peripheral Unit Speed High Low Capacity Huge ( GB,TB) Limited (4GB , 8GB) Storage Temporary Permanent Storage Volatile Non Volatile Cost High Cheap Manufacturing technology Semiconductor devices
  • 7. Binary Storage 0 1 0 1 1 1 1 0 0 1 1 1 0 0 0 0 0 0 1 1 0 0 0 0 0 byte = 8 bits (0) word = 2 bytes = 16 bits (3,4) double word = 2 words = 32bits (6,7,8,9) 0 1 2 3 4 5 6 7 8 9 A B
  • 8. Types of programming Languages Machine Level / Code • Contains binary coded instructions from CPUs instruction set • Processor can process them directly without any transformation. - executable • Hardware dependent • Programmer needs to know processor architecture 8B542408 83FA0077 06B80000 0000C383 FA027706 B8010000 00C353BB 01000000 B9010000 008D0419 83FA0376 078BD98B C84AEBF1 5BC3 Assembly Level / Language • Mapping of human readable symbols of machine codes - mnemonics +operands • One to one correspondence between assembly statement and machine code • Is specific to hardware
  • 9. Types of programming languages High Level Language • Machine (Processor) independent English like language with high level of abstraction • Closer to natural language , easier to use and more understandable • Non executable •
  • 10. Types of programming Languages
  • 13. • A high-level programming language interpreted by another program at runtime • Scripts are tasks written for environment & interpreted at runtime in a batch • Script requires an interpreter or a virtual machine at run time • Explicit compilation or linking phases are not needed • Variables, functions, and methods typically do not require type declarations. • Source code is present at run time and compiled into native object code. •JavaScript, ASP, JSP, PHP, Perl, Python Scripting Language
  • 14. Natural Language • Programming in terms of natural language sentences, e.g. English • The smallest unit of statement in NLP is a sentence. • In an NLP text every sentence compiles into a procedure call in the underlying high level programming language such as MATLAB, Octave, SciLab, Python, etc. Advantages and limitations of different levels of languages - Home work Examples - Mathematica. , Wolfram Alpha , Inform7 , Thinknowlogy,
  • 15. Characteristics of a good programming language -1 1. Responsiveness • e.g. excel • Read-evaluation –print –loop (REPL) • there should be less steps between changing code and seeing results • More steps in REPLs destroyed program flow • Small-talk and LISP have powerful REPLs 2. Safety • provided by compilers so that even a smallest error can be detected before a program is run • Languages data type system is often a source of programming error • Haskell has a powerful type system • Dynamic type setting is risky - you need to run the program 3. Speed • Sometimes we need the compile code that runs fast … • It depends on language and memory layout or structure • Best way to speed up code is to improve the algorithm • C is the fastest high level language
  • 16. Characteristics of a good programming language -1 4. Completeness • A language rich with libraries is preferred 5. Expressiveness • Expressiveness is the ability to reshape the language until you can express your program naturally. • Lisp and Scheme let you implement a new internal language for describing your program concisely. • Smalltalk, Ruby and Haskell have basic building blocks and lightweight syntax that makes it easy to define new language constructs for your particular problem. • This property is very important because code is to be read by humans first and then computers
  • 17. 1. Readability: Should allow programs to be written in ways that 2. Portability: Should be able to develop portable software. 3. Generality: Writing of a wide variety of programs, thus relieving the programmer of the need to become expert in many diverse languages. 4. Brevity: Ability to implement the algorithm with less amount of code. 5. Error checking:. Error checking both at compile-time and at run-time. 6. Familiar notation: A language should have familiar notation, so it can be understood by most of the programmers. 7. Quick translation: It should admit quick translation. 8. Efficiency: It should permit the generation of efficient object code. 9. Modularity: It is desirable that programs can be developed in the language as a collection of separately compiled modules, with appropriate mechanisms for ensuring self-consistency between these modules. 10 Widely available: Language should be widely available and it should be possible to provide translators for all the major machines and for all the major operating systems. A good programming language -2
  • 19. C Programming Character set - is set of characters used to form constants, variables and expressions Categories of C character set A. Letters B. Digits C. Special Characters D. White-spaces •Letters - A…Z , a…..z • Digits - 0….9 • White spaces • blank • horizontal tab •Carriage return • New line • Form feed
  • 20. C Programming Special Characters , Comma & Ampersand . Period ^ Caret ; Semicolon * asterisk : colon - Minus ? Question mark + Plus ‘ Apostrophe < Opening angle bracket ! Exclamation > Closing angle bracket | Vertical bar ( left parenthesis / Slash ) Right parenthesis “ Quotation mark Back slash ~ Tilde [ Left bracket _ Underscore ] Right bracket $ Dollar sign { Left brace % Percentage sign } Right brace # Number sign
  • 21. C Tokens • C language statements are made of tokens •Tokens are smallest recognizable units of language • Any C language statement consists of following six types of tokens 1. Keywords - language specific words with special meaning - float , if , int , while , 2. Identifiers - user defined names of variables , functions etc - main , age , etc … 3. Constant or literals - 12, 57, 38.69, 99.6756, 4. String - ‘A’, ‘ Vishwakarma’ 5. Operators - + , - , * , = , ++ , -- 6. Special symbol - , [] , {} , % Example - identify tokens void main(void) { int age = 28 ; clrscr(); printf(“My age is %d”, age); }
  • 22. auto double int struct break else long switch case enum register typedef char extern return union const float short unsigned continue for signed void default goto sizeof volatile do if static while 1. Keywords •All keywords have fixed meanings which can not be changed •Key words are basic building blocks of a statement
  • 23. 2. Identifiers • These are names of variables and functions or arrays which are user defined • Contain sequence of letters, digits Rules of naming identifiers 1. First character must be alphabet 2. Must have letters , digits and underscore only 3. Length can be 31 maximum 4. Cannot use a keyword 5. Must not have any white spaces
  • 24. 3. Integer Constants • These are fixed values that do not change • Integer constants - sequence of digits • Decimal integers - will have 0 to 9 with optional + or - • 123,567, -45, 0 , 653456 • Octal integers - will have 0 to 7 with optional + or - and with leading zero • 037 , 0 , 0435 , 0551 • Hexadecimal integers - will have 0 to A with optional + or - and with leading 0x • 0x2 , 0x , 0xBCD , 0x3FFF •Largest value that can be stored is machine dependant • 16 bit machine can store can store maximum integer = 32767 = 215 - 1 • 32 bit machine can store can store maximum integer = 2147483647 = 231 - 1 • Integer constant can be unsigned or signed or long • 56789U ( unsigned integer ) •89776788UL ( unsigned long integer ) •786756L ( long integer ) http://www.tutorialspoint.com/ansi_c/c_using_constants.htm •
  • 25. 3. Floating point or real Constants • These are fixed values that do not change • Real or floating point constants - numbers with fractional parts • 0.0083 , -0.75 , +247.45 , 215. . .95 , -.71 , +.5 (omit digit before after .) • Scientific notation of real numbers • mantissa e exponent • mantissa can be real number but exponent is always an + or - integer • exponent causes decimal point to float so called as floating point form • 0.65e4 12e-2 , 1.5e+5 3.18E3 - 1.2E-1 • This notation is used to represent very large or very small numbers • 750000000000  7.5E9 • -0.0000000000000000000000000368  -3.68E-26
  • 26. 3. Constants - Find naming errors Number Valid ? Remarks 698345L 25,000 +5.0E3 3.5e-5 7.1e4 -4.5e-2 1.5E+2.5 $255 0X7B
  • 27. 3. Constants - Find naming errors Number Valid ? Remarks 698345L Yes Long integer 25,000 No Comma not allowed +5.0E3 Yes 3.5e-5 Yes 7.1e 4 No No white space permitted -4.5e-2 Yes 1.5E+2.5 No Exponent must be integer $255 No $ not permitted 0X7B Yes Hexadecimal integer
  • 28. 3. Single Character constants • contains single character enclosed in single quotes • ‘5’ ‘X’ ‘;’ ‘ ‘ ‘’ ‘Z’ • note 5 is integer but ‘5’ is character • each character constant is stored internally with an ASCII code printf(“%d”, ‘a’)  would display 97 printf(“%d”, ‘108’)  would display l
  • 29. 4. String constants • contains sequence of characters enclosed in double quotes • “Hello” , “1987” , “5+3-2=?” • it may have letters , digits and special characters • string constant “A” or “8” does not have an integer value • ‘5’ and “5” are different • C compiler automatically store character ‘0’ at the end of every defined string constant
  • 30. 4. Escape Sequences - Single Character Constant ‘a’ bell ‘b’ back space ‘f’ form feed ‘n’ New line ‘t’ Horizontal tab ‘v’ Vertical tab ‘’’ Single quotes ‘’ Double quotes ‘0’ null Special character constants - Escape sequences
  • 32. Variables • Variable is a data name used to store a value that can change • variable can take different values during program execution • a variable should have a meaningful name • average , sex , age , total , counter , lineno etc Name Valid ? Remark First_tag char Price$ group one average _number int_type
  • 33. Variables Name Valid ? Remark First_tag Valid char Not Valid char is keyword Price$ Not Valid Dollar illegal group one Not Valid Blank space average _number Valid int_type Valid
  • 34. Data Types • Variety of data types allow programmer to select type appropriate to the needs and the processor • There are three 3 classes of data types in ANSI C • Primary or primitive data types - int , char , float , void • Derived data types - arrays , structures , pointers , functions • User defined data types - typedef , enum Primitive data types Data type Size Range of values Char 1 byte -128 to 127 Int 2 bytes - 32768 to 32767 Float 4 bytes 3.4e-38 to 3.e+e38 Double 8 Bytes 1.7e-308 to 1.7e+308
  • 35. Data Types •Integer type • whole numbers • range supported by a specific machine • occupy one word ) • word size depends on processor - 16 or 32 • for 16 bit processor - integer values are -215 to 215-1 • default is signed integer which stores sign of number in last bit • short int - half the word size • int - - word size • long int - double the word size • unsigned integers use all bits for magnitude • long and unsigned can increase range of values required to be stored Type Size Type Size char 8 long int 32 int or signed int 16 unsigned long int 32 unsigned int 16 float 32 short int 8 double 64 unsigned short int 8 long double 80 long int int short int
  • 36. Data Types • Floating point type • Real numbers stored in 32 bit format • keyword - float , double used when higher accuracy required • double uses 64 bits storage space - known as double precision number • floating point describes a method of representing an approximation of a real number in a way that can support a wide range of values. • It has fixed number of significant digits (the mantissa) and scaled using an exponent • Significant digits × baseexponent • • Void Type • void type has no values • used to specify function type • function is void if it does not return any value to calling function • it can also represent generic type long double double float
  • 37. Data Types • Character types • Single character can be defined as character type data • They are stored in 8 bits (one byte) • unsingned char  0 to 255 values • signed char  -127 to 127
  • 38. Variable declarations • tells compiler what the variable name is • tells compiler what type of data it will store • declaration must be done before they are used in program <data type> <variable 1>, *<variable2> , ….+ Primary type declaration int count ; • int sum, total; • char choice; • float ratio,x,y; • short int row; • long int amount ; • double deviation ; • char c; • unsigned n; ( short , long , unsigned without data type is treated as integer) • qualifiers  signed , unsigned , short , long •
  • 39. Constants Integer constants +111 int -222 int 45678U unsigned int -56789L long int 987654UL unsigned long t Real constants 0. double .0 double 12.0 double 1.234 double -1.2f float 1.234567L long double
  • 40. Defining symbolic constants • defining macro definitions • use #define which is a preprocessor directive • does not end with a semicolon • placed before main • used to define symbolic constants like pi etc • #define pi 3.142 • #define name Yogesh • #define VIIT Vishwakarma Institute of information technology • # define STRENGTH 100 • # define PASS_MARK 50 • # define ASCII_A 65 • # define ASCII_Z 95
  • 41. Defining symbolic constants • #define X=2.5 • # define MAX 10 - white space • #define N 25; • #define N 5, M 10 - multiple not allowed • #Define ARRAY 11
  • 42. Comments Comments are used for documentation purpose Statements enclosed in /* and */ are not compiled Multiple lines can be commented by puttiong /* at start and */ at the end. /* Include function declarations */ #include<stdio.h> #include<conio.h> Void main(void) { /* Variables */ int x ; char y; int num[15]; printf(“nEnter age : “); scanf(”%d”,&x); }
  • 43. Operators and expressions • Arithmetic Operators • + addition or nary plus • - subtraction or us nary minus • * multiplication • / division • % Modulo division • Integer division truncates fractional part • % can not be used on floating point numbers • C does not have a operator for exponent • During modulo division sign of first operand is sign of the result • -14 % 3 = -2 • -14 % -3 = -2 • 14 % -3 = 2
  • 44. Operators and expressions • Relational Operators • < , <= , > , >= , == ! = • if expression is zero it is false else true. • if expression1 operator expression2 - first expression is evaluated and then the results are compared • Arithmetic operator have higher priority over relational operators • > complement of <= • < complement of >= • == complement of != • !(x<y)  x<=y • !(x==y)  x!=y • !(x<=y)  x > y
  • 45. Operators and expressions • Logical Operators - combining multiple conditions • && - logical AND • || - logical OR • ! - logical NOT if (age > 55 && salary < 1000) if ( number < 0 || number > 100) Precedence Highest ! > >= < <= == != && Lowest ||
  • 46. Operators and expressions • Assignment Operator • Used to assign result of an expression = • Shorthand assignment += , -= • x+=y+1  x=x+(y+1) • x+=3  x=x+3 • a=a+1  a+=1 • a=a-1 -> a-=1 • a=a*(n+1)  a*=(n+1) • a = a / (n+1)  a/= (n+1) • a=a%b  a%=b
  • 47. Operators and expressions • Increment and decrement Operator • ++ m 0r m++ and --m or m— • prefix ++ or -- increments or decrements variable & then uses in expression • postfix ++ or -- uses current value in expression and then increments or decrements variable • eg. a=3 ; b=5 ; c=10 ; z=0 • z=a++; • b=--c; • a=z--; what are values in a, b, c and z at the end • y=a++ -b-- +--c ; • Can also be used in subscripted variables e.g. num[i++]=10 ; • Rules : •
  • 48. Operators and expressions • Conditional Operator • Ternary operator • exp1 ? exp2 : exp3 - exp1 is conditional statement • if exp1 is non zero or true exp2 is evaluated else exp3 evaluated a=10 b=15 x= (a>b) ? a: b; if ( a>b) x=a; else x=b;
  • 49. Operators and expressions • Precedence of operators • An expression without parenthesis will be evaluated left to right using rules of precedence of operators • Two levels of priority in arithmetic operators • High - * / % • Low - + - • first pass  high priority operators are applied • second pass  low priority operators are applied • x=a-b/3+c*2-1 a=9 b=12 c=3 • First pass  9-(12/3)+(3*2)-1 and a-4+6-1 • Second pass  5+6-1 , 11-1 , 10 •E.g. 9-12/(3+3)*(2-1) • 1st pass  9-12/6*(2-1) and 9-12/6*1 • 2nd pass  9-2*1 and 9-2 • 3rd pass  7
  • 50. Operators and expressions • Precedence of operators • parenthesis may be nested --- in such cases evaluation of the expression will proceed outward from the innermost set of parenthesis. • 9-(12/(3+3) * 2) -1 = ? • 9-((12/3)+3 *2)-1 = ? • Rules • First parenthesized sub-expressions from left to right are evaluated • If nested parenthesis evaluation begins from innermost sub-expression • Precedence rule of operators is then applied • Associative rule applied if two operators of same level appear • Arithmetic expressions are evaluated form left to right using rules of precedence • Expression within parenthesis assume highest priority
  • 51. Operators and expressions int a a= 5 <=8 && 6!=5 ; printf(“%d”, a); getch(); Answers =1 some computational problems (A) Division of frictional numbers a= 1.0 / 3.0; b= a * 3.0 ; What is value of b ? (B) Divide by zero
  • 52. Operators and expressions (B) Overflow or underflow - operand should be of correct type and size otherwise there will round-off errors introduced float sum, n, term; int count = 1; sum=0 ; printf (“Enter value of n n”); scanf(“%f”,&n); term= 1.0/n; while ( count <=n) { sum= sum + term; count++; } printf(“ Sum = %fn”, sum); } Output Enter value of n 99 Sum= 1.000001 Enter value of n 143 sum= 0.999999
  • 53.
  • 54.
  • 55.
  • 56.
  • 57.
  • 58.
  • 59.
  • 60.
  • 61. String Handling #include<stdio.h> #include<conio.h> void main(void) { /* Input a string */ char string[25]; clrscr(); printf("Input a string : "); scanf("%s",string);
  • 62. String Handling /* Find length of string */ i=0; slen=0; while(string[i]!='0') { slen++; i++; } printf("nString length : %d",slen);
  • 63. String Handling /* Dislay string in reverse order */ i=slen; printf("nReverse string : "); while(i>=0) { printf("%c",string[i]); i--; }
  • 64. String Handling /* Find number of vowels in string */ i=slen; while(i>=0) { switch(string[i]) { case 'A' : case 'a' : case 'E' : case 'e' : case 'I' : case 'i' : case 'O' : case 'o' : case 'U' : case 'u' : Nvowels++; break; } i--; } printf("nNumber of vowels : %d",Nvowels);
  • 65. String Handling /* Find number of 'a' or 'A' in string */ Na=0; for(i=0; i<slen; i++) { if(string[i] =='a' || string[i] == 'A') Na++; } printf("nTotal number of charater 'a' or 'A' : %d ",Na);
  • 66. String Handling /* Check is string is palindrome */ i=0; j=slen-1; while(string[i]==string[j]) { i++; j--; if(i>j) break; } if(i>=j) printf("nString is palindrome"); else printf("nString is not a palindrome"); getch();
  • 69. Extra
  • 70. 3. Constants - Find naming errors
  • 71.
  • 72. • Binary code • Assembly language  Assembles • Low-level programming languages (Like C, C++, B, D, fortain, objc, simula...) •High-level languages (Like C++.NET, erlang) -> very high/goal level programming languages • Low level interpreted languages (like Java, C#...) -> • Mid level (Python, Ruby) -> •high level (no bytecode) interpreted languages (Bash, PHP, Lua) -> "Structure interpeted"
  • 73. • A high-level programming language that is interpreted by another program at runtime rather than compiled by the computer's processor as other programming languages (such as C and C++) •Programming language where scripts / programs written for a special runtime environment that will interpret/automate tasks which could be executed one-by-one by a human • For instance, one could put a series of editing commands in a file, and tell an editor to run that "script" as if those commands had been typed interactively. • Scripts are tasks written for runtime environment and interpreted at runtime in a batch • Many programs can be together pipelined in script -- eg. Shell script in Linux • The primary focus isn't primarily building your own apps so much as getting an existing app to act the way you want, • Scripting is used to configure web pages within browser , shells of OS •Typically, a scripting language is characterized by the following properties • Ease of use. - very fast to learn has simple syntax and semantics. • OS facilities - Scripting is usually aimed at desktops, limiting the portability needs of the pre-built libraries. • Interpreted from source code - to give the fastest turnaround from script to execution. • Relatively loose structure. It would be difficult to use Java as a scripting language due to the rules about which classes exist in which files - contrast to Python, where it's possible to simply define some functions in a file. • An interpreter or a virtual machine is required Scripting Language
  • 74. •Source code is present at run time in production system and compiled into native object code. • Use of an interpreter or Virtual Machine is generally required; though the OS may arrange for the appropriate interpreter to be invoked automatically. •Explicit compilation or linking phases are not needed •Variables, functions, and methods typically do not require type declarations. . •Very powerful built-in types - typically a dictionary, a set, a literal type that can act as either numeric or strings. •The ability to generate, load, and interpret source code at run time through an eval function. (Perl, Python, Tcl, JavaScript, shell scripts, REXX, APL; •Interface to the underlying operating system, in order to run other programs and communicate with them. •Rich I/O capabilities, including pipes, network sockets, file I/O, and file system operations. Properties of a scripting language
  • 75. Characteristics of a good programming language -1 • Vocabulary should resemble English (or some other human language). • Programs should consist of instructions- tedious declarations should be kept to a minimum. • The language , its classes or functions in libraries should be fully documented. •There should be no need to manipulate pointers explicitly no means of doing so. They should be managed by the language and not by the programmer. •The language should provide arrays of unlimited size: there should be no need to declare array bounds. •Sorting facilities should be included as standard; we shouldn't have to write our own sort routines. •The language should provide full facilities for handling a graphical user interface. These • Should be able to keep one project separate from another and projects should be separated from libraries supplied with the language.