SlideShare ist ein Scribd-Unternehmen logo
1 von 44
Downloaden Sie, um offline zu lesen
Review of Basic Programming
Concepts
Lecture No 1
COMSATS Institute of Information Technology

1

Object Oriented Programming
Basics of Typical C Program
Development Environment
A program development environment
The language
C Standard Library

2

Object Oriented Programming
Six phases to be executed
Edit
Preprocessor
Compile
Link
Load
Execute

3

Object Oriented Programming
Stages of compilation
Preprocessing
Performed

by a program called the preprocessor
Modifies the source code (in RAM) according to
preprocessor directives (preprocessor commands)
embedded in the source code
Strips comments and white space from the code

4

Object Oriented Programming
Compilation
Performed by a program called the compiler
Translates the preprocessor-modified source code into object

code (machine code)
Checks for syntax errors and warnings
o If any compiler errors are received, no object code file will be generated.
o An object code file will be generated if only warnings, not errors, are

received.

5

Object Oriented Programming
Linking
Combines the program object code with other object code to

produce the executable file.
The other object code can come from the Run-Time
Library, other libraries, or object files that you have created.
Saves the executable code to a disk file
o If any linker errors are received, no executable file will be generated.

6

Object Oriented Programming
Simple c program
/* Filename:
product.c
Description: This program prompts the user for two integer values then displays
their product.
*/

#include <stdio.h>
int main( void )
{
int value1, value2, product ;
printf(“Enter two integer values: “) ;
scanf(“%d%d”, &value1, &value2) ;
product = value1 * value2 ;
printf(“Product = %dn”, product) ;
return 0 ;
}
7

Object Oriented Programming
Anatomy of c program
program header comment
preprocessor directives (if any)
int main ( void )
{
statement(s)
return 0 ;
}
8

Object Oriented Programming
A comment is descriptive text used to help a reader of the

program understand its content.
Lines that begin with a # are called preprocessor directives
(commands).
Every program must have a function called main. This is where
program execution begins.
A left brace (curly bracket) -- { -- begins the body of every
function. A corresponding right brace -- } -- ends the function
body.

9

Object Oriented Programming
int value1, value2, product;
Declaration of variables
 Variables: locations in memory where a value can be stored

int means the variables can hold integers (-1, 3, 0, 47)
Variable names (identifiers)
 value1, value2, product
 Identifiers: consist of letters, digits (cannot begin with a digit) and

underscores( _ )
 Case sensitive

Declarations appear before executable statements
 If an executable statement references and undeclared variable it will

produce a syntax (compiler) error
10

Object Oriented Programming
scanf("%d%d", &value1,&value2);
Obtains values from the user
 scanf uses standard input (usually keyboard)
This scanf statement has two arguments
 %d - indicates data should be a decimal integer
 &value1 - location in memory to store variable

When executing the program the user responds to the scanf

statement by typing in a number, then pressing the enter
(return) key

11

Object Oriented Programming
= (assignment operator)
Assigns a value to a variable
Is a binary operator (has two operands)
product = value1 * value2;

Variable receiving value on left

printf( “Product is %dn", product);
Similar to scanf
 %d means decimal integer will be printed
 product specifies what integer will be printed

12

Object Oriented Programming
Arithmetic

Arithmetic operators:
C operation
Addition
Subtraction
Multiplication
Division
Modulus

Arithmetic
operator
+
*
/
%

Algebraic
expression
f+7
p–c
bm
x/y
r mod s

Rules of operator precedence:
Operator(s)
()

f
p
b
x
r

+
*
/
%

7
c
m
y
s

Order of evaluation (precedence)
Evaluated first. If the parentheses are nested, the
expression in the innermost pair is evaluated first. If there
are several pairs of parentheses “on the same level” (i.e.,
not nested), they are evaluated left to right.
Multiplication,Divi Evaluated second. If there are several, they are
*, /, or %
sion, Modulus
evaluated left to right.
Addition
Evaluated last. If there are several, they are
+ or Subtraction
evaluated left to right.
Object Oriented Programming

13

Operation(s)
Parentheses

C expression
Decision Making: Equality and
Relational Operators
 Executable statements

 Perform actions (calculations, input/output of data)
 Perform decisions
 May want to print "pass" or "fail" given the value of a test grade

 if control structure

 Simple version in this section, more detail later
 If a condition is true, then the body of the if statement executed
 0 is false, non-zero is true
 Control always resumes after the if structure

 Keywords

 Special words reserved for C
 Cannot be used as identifiers or variable names

14

Object Oriented Programming
Decision Making: Equality and
Relational Operators
Standard algebraic
equality operator or
relational operator

C equality or
relational
operator

Example of C Meaning of C
condition
condition

==
!=

x == y

x is equal to y

x != y

x is not equal to y

x > y

x is greater than y

<

>
<

x < y

x is less than y

>=

>=

x >= y

x is greater than or
equal to y

<=

<=

x <= y

x is less than or
equal to y

Equality Operators

=
not =
Relational Operators

>

15

Object Oriented Programming
Control Structures
Control Flow
In C, three ways to specify sequence of statement execution
Sequential Execution
Conditional Execution
Iterative Execution

16

Object Oriented Programming
Conditional Execution
One-way selection or if
Two-way selection or if-else
Multiple Selection or nested if

17

Object Oriented Programming
One-way selection or if
If(expression)

statement1;
If(x>10)
y=z/x;
y=z*x;
If(x>y)
printf(“the largest is %d”,x);

18

Object Oriented Programming
Two-way selection or if-else
If(expression)

statement1;
else
statement2;
If(x>y)
printf(“the largest is %d”,x);
else
printf(“the largest is %d”,y);

19

Object Oriented Programming
Multiple Selection or nested if
If(condition1)

{
if(condition2)
statement1;
}
else
statement2;

20

Object Oriented Programming
Iterative Execution
The while statement
The for statement
The do-while statement

21

Object Oriented Programming
The while statement
 While(expression)

statement1;
#include<stdio.h>
int main()
{
Int k, num, maximum=10;
k=1;
while(k<=maximum)
{
scanf(“%d”, &num);
printf(“%4d”, num);
k++;
}
return 0;
}

22

Object Oriented Programming
The for statement
for(expression1;expression2;expression3)

statement1;
expression1: initial value
expression2: boolean expression
expression3: update of expression

23

Object Oriented Programming
Example
#include<stdio.h>
int main()
{
int sum, n, i;
sum = 0;
scanf(“%d”, &n);
for(i=1; i<=n; i++)
sum = sum + i;
printf(“Sum=%dn”,sum);
return 0;
}

24

Object Oriented Programming
The do-while statement
do
statement1
while(expression);

25

Object Oriented Programming
Example
#include<stdio.h>
int main()
{
int sum, num;
sum = 0;
num=1;
do
{
sum = sum + num;
num++;
}
while(num <= 10);
printf(“Sum=%dn”,sum);
return 0;
}

26

Object Oriented Programming
Other Control Structures
switch
break
continue

27

Object Oriented Programming
Example
#include<stdio.h>
int main()
{
int n;
printf(“Enter an integer valuen” );
scanf(“%d”, &n);
switch(n)
{
case 1: printf(“The value is 1n”);
break;
case 2: printf(“The value is 2n”);
break;
default: printf(“The value is neither 1 nor 2n”);
}
return 0;
}

28

Object Oriented Programming
Functions
An independent set of statements for performing some

special tasks
Attributes
Name of function (user-defined)
Parameters
Variable declaration (if any)
The body of function

29

Object Oriented Programming
Divisions of Function
Prototype

int largest(int x, int y);
Definition Head

function itself
Invocation

large = largest (x, y);

30

Object Oriented Programming
Types of Function
 System-supplied functions
To instruct system to accomplish specific operations
Saves programmers time to writing own functions
Completely debugged, efficient and always produce precise output
Reduce source code
printf(“%d”, x);

 User-defined functions
Defined by programmer as part of source code
Result-type user-defined-name(parameters)

31

Object Oriented Programming
User-defined function
#include<stdio.h>
int retlarge(int num1, int num2);
int main()
{
int num1, num2, large;
scanf(“%d%d”, &num1, &num2) ;
printf(“%d %dn”, num1, num2) ;
large = retlarge(num1, num2);
printf(“large = %dn”, large);
return 0;
}
int retlarge(int x, int y)
{
if (x>y)
return(x);
else
return(y);
}

32

Object Oriented Programming
Methods for transmitting parameters
Passing by value
treated as local variables
the initial value is obtained by copying the values of associated

actual parameters
Passing by location
passing by address or reference
linking actual parameters to formal parameters by passing

address of actual parameters from the calling program to called
program

33

Object Oriented Programming
Arrays
 Group of elements of same type.
 Collection of similar data type

stored in contiguous memory
location.
 To refer to an element, specify

Name of array
(Note that all
elements of this
array have the
same name, c)
c[0]

-45

c[1]

6

c[2]

0

c[3]

72

c[4]

1543

c[5]

-89

arrayname[ position number ]

c[6]

0

 First element at position 0
 n element array named c:
 c[ 0 ], c[ 1 ]...c[ n – 1 ]

c[7]

62

c[8]

-3

c[9]

1

 Array name
 Position number

 Format:

c[10]
c[11]

34

Object Oriented Programming

6453
78

Position number
of the element
within array c
Declaring Arrays
 When declaring arrays, specify

Name
Type of array
Number of elements
arrayType arrayName[ numberOfElements ];
Examples:
int c[ 10 ];
float myArray[ 3284 ];

 Declaring multiple arrays of same type
Example:
int b[ 100 ], x[ 27 ];

35

Object Oriented Programming
 Initializers

int n[ 5 ] = { 1, 2, 3, 4, 5 };

If not enough initializers, rightmost elements become 0

int n[ 5 ] = { 0 }
 All elements 0

If too many a syntax error is produced syntax error
C arrays have no bounds checking

 If size omitted, initializers determine it
int n[ ] = { 1, 2, 3, 4, 5 };

5 initializers, therefore 5 element array

36

Object Oriented Programming
 Character arrays

 String “first” is really a static array of characters
 Character arrays can be initialized using string literals
char string1[] = "first";
 Null character '0' terminates strings
 string1 actually has 6 elements
 It is equivalent to
char string1[] = { 'f', 'i', 'r', 's', 't', '0' };
 Can access individual characters
string1[ 3 ] is character ‘s’
 Array name is address of array, so & not needed for scanf
scanf( "%s", string2 );
 Reads characters until whitespace encountered
 Can write beyond end of array, be careful

37

Object Oriented Programming
Array Subscripting Formula
Address of i-th element = address of 0-th element + i * (size

of type)
Assuming declaration int intarr[10];
Assuming address of array intarr is located at address 10 in
memory
Accessing element intarr[5] can be calculated by formula:
Address of i-th element = 10 + 5 * 2 = 20

38

Object Oriented Programming
Pointers
Pointers are variables that contain memory addresses as their

values.

A variable name directly references a value.
A pointer indirectly references a value. Referencing a value

through a pointer is called indirection.

A pointer variable must be declared before it can be used.

39

Object Oriented Programming
 Memory can be conceptualized as a linear set of data locations.
 Variables reference the contents of a locations
 Pointers have a value of the address of a given location
 A declaration int intval=10;
Then int ptr can be set as int *ptr;
Pointing to intval by ptr = &intval;
Address of intval assigned to ptr, not contents!

40

Object Oriented Programming
& and *
 When is & used?
 When is * used?
 & -- "address operator" which gives or produces the memory

address of a data variable
 * -- "dereferencing operator" which provides the contents in the
memory location specified by a pointer

41

Object Oriented Programming
Pointers and Function
Pointers can be used to pass addresses of variables to called

functions, thus allowing the called function to alter the values
stored there.
If instead of passing the values of the variables to the called
function, we pass their addresses, so that the called function
can change the values stored in the calling routine. This is
known as "call by reference" since we are referencing the
variables.

42

Object Oriented Programming
Passing pointers to function
#include <stdio.h>
void exchange ( int *a, int *b ) ;
int main ( )
{
int a = 5, b = 6;
printf("a=%d b=%dn",a,b) ;
exchange (&a, &b) ;
printf("a=%d b=%dn",a,b) ;
return 0 ;
}

43

Object Oriented Programming
void exchange( int *a, int *b )
{
int temp;
temp= *a; *a= *b; *b = temp ;
printf ("a=%d b=%dn", *a, *b);
}
Results:
a=5 b=6
a=6 b=5
a=6 b=5

44

Object Oriented Programming

Más contenido relacionado

Was ist angesagt?

Ch10 Program Organization
Ch10 Program OrganizationCh10 Program Organization
Ch10 Program OrganizationSzeChingChen
 
FUNCTION IN C PROGRAMMING UNIT -6 (BCA I SEM)
 FUNCTION IN C PROGRAMMING UNIT -6 (BCA I SEM) FUNCTION IN C PROGRAMMING UNIT -6 (BCA I SEM)
FUNCTION IN C PROGRAMMING UNIT -6 (BCA I SEM)Mansi Tyagi
 
Basic structure of c programming
Basic structure of c programmingBasic structure of c programming
Basic structure of c programmingTejaswiB4
 
C language for Semester Exams for Engineers
C language for Semester Exams for Engineers C language for Semester Exams for Engineers
C language for Semester Exams for Engineers Appili Vamsi Krishna
 
Complete C programming Language Course
Complete C programming Language CourseComplete C programming Language Course
Complete C programming Language CourseVivek chan
 
Programming Fundamentals Functions in C and types
Programming Fundamentals  Functions in C  and typesProgramming Fundamentals  Functions in C  and types
Programming Fundamentals Functions in C and typesimtiazalijoono
 
C programming Workshop
C programming WorkshopC programming Workshop
C programming Workshopneosphere
 
Sample for Simple C Program - R.D.Sivakumar
Sample for Simple C Program - R.D.SivakumarSample for Simple C Program - R.D.Sivakumar
Sample for Simple C Program - R.D.SivakumarSivakumar R D .
 
Recursive Function
Recursive FunctionRecursive Function
Recursive FunctionHarsh Pathak
 

Was ist angesagt? (18)

Ch10 Program Organization
Ch10 Program OrganizationCh10 Program Organization
Ch10 Program Organization
 
Ch9 Functions
Ch9 FunctionsCh9 Functions
Ch9 Functions
 
Learning the C Language
Learning the C LanguageLearning the C Language
Learning the C Language
 
FUNCTION IN C PROGRAMMING UNIT -6 (BCA I SEM)
 FUNCTION IN C PROGRAMMING UNIT -6 (BCA I SEM) FUNCTION IN C PROGRAMMING UNIT -6 (BCA I SEM)
FUNCTION IN C PROGRAMMING UNIT -6 (BCA I SEM)
 
Ch4 functions
Ch4 functionsCh4 functions
Ch4 functions
 
Function in C program
Function in C programFunction in C program
Function in C program
 
Basic structure of c programming
Basic structure of c programmingBasic structure of c programming
Basic structure of c programming
 
Functions in c
Functions in cFunctions in c
Functions in c
 
C language for Semester Exams for Engineers
C language for Semester Exams for Engineers C language for Semester Exams for Engineers
C language for Semester Exams for Engineers
 
Complete C programming Language Course
Complete C programming Language CourseComplete C programming Language Course
Complete C programming Language Course
 
Function C programming
Function C programmingFunction C programming
Function C programming
 
Programming Fundamentals Functions in C and types
Programming Fundamentals  Functions in C  and typesProgramming Fundamentals  Functions in C  and types
Programming Fundamentals Functions in C and types
 
C programming Workshop
C programming WorkshopC programming Workshop
C programming Workshop
 
Sample for Simple C Program - R.D.Sivakumar
Sample for Simple C Program - R.D.SivakumarSample for Simple C Program - R.D.Sivakumar
Sample for Simple C Program - R.D.Sivakumar
 
Recursive Function
Recursive FunctionRecursive Function
Recursive Function
 
C# programs
C# programsC# programs
C# programs
 
3 Function & Storage Class.pptx
3 Function & Storage Class.pptx3 Function & Storage Class.pptx
3 Function & Storage Class.pptx
 
Ch4 Expressions
Ch4 ExpressionsCh4 Expressions
Ch4 Expressions
 

Andere mochten auch

Pak US relation 130411005046-phpapp01
Pak US relation 130411005046-phpapp01Pak US relation 130411005046-phpapp01
Pak US relation 130411005046-phpapp01Asfand Hassan
 
Oop lec 2(introduction to object oriented technology)
Oop lec 2(introduction to object oriented technology)Oop lec 2(introduction to object oriented technology)
Oop lec 2(introduction to object oriented technology)Asfand Hassan
 
Programming fundamentals lecture 1&2
Programming fundamentals lecture 1&2Programming fundamentals lecture 1&2
Programming fundamentals lecture 1&2Raja Hamid
 
[1]اساسيات تفاعل الانسان مع الحاسوب
[1]اساسيات تفاعل الانسان مع الحاسوب[1]اساسيات تفاعل الانسان مع الحاسوب
[1]اساسيات تفاعل الانسان مع الحاسوبتامنيت نلالوت
 
Fundamental Programming Lect 1
Fundamental Programming Lect 1Fundamental Programming Lect 1
Fundamental Programming Lect 1Namrah Erum
 

Andere mochten auch (6)

Pak US relation 130411005046-phpapp01
Pak US relation 130411005046-phpapp01Pak US relation 130411005046-phpapp01
Pak US relation 130411005046-phpapp01
 
Oop lec 2(introduction to object oriented technology)
Oop lec 2(introduction to object oriented technology)Oop lec 2(introduction to object oriented technology)
Oop lec 2(introduction to object oriented technology)
 
Programming fundamentals lecture 1&2
Programming fundamentals lecture 1&2Programming fundamentals lecture 1&2
Programming fundamentals lecture 1&2
 
Programming Fundamentals
Programming FundamentalsProgramming Fundamentals
Programming Fundamentals
 
[1]اساسيات تفاعل الانسان مع الحاسوب
[1]اساسيات تفاعل الانسان مع الحاسوب[1]اساسيات تفاعل الانسان مع الحاسوب
[1]اساسيات تفاعل الانسان مع الحاسوب
 
Fundamental Programming Lect 1
Fundamental Programming Lect 1Fundamental Programming Lect 1
Fundamental Programming Lect 1
 

Ähnlich wie Oop lec 1

Complete C++ programming Language Course
Complete C++ programming Language CourseComplete C++ programming Language Course
Complete C++ programming Language CourseVivek chan
 
Datastructure notes
Datastructure notesDatastructure notes
Datastructure notesSrikanth
 
Fundamentals of computer programming by Dr. A. Charan Kumari
Fundamentals of computer programming by Dr. A. Charan KumariFundamentals of computer programming by Dr. A. Charan Kumari
Fundamentals of computer programming by Dr. A. Charan KumariTHE NORTHCAP UNIVERSITY
 
VIT351 Software Development VI Unit1
VIT351 Software Development VI Unit1VIT351 Software Development VI Unit1
VIT351 Software Development VI Unit1YOGESH SINGH
 
C decision making and looping.
C decision making and looping.C decision making and looping.
C decision making and looping.Haard Shah
 
C++ programming language basic to advance level
C++ programming language basic to advance levelC++ programming language basic to advance level
C++ programming language basic to advance levelsajjad ali khan
 
chapter-2.ppt
chapter-2.pptchapter-2.ppt
chapter-2.pptXanGwaps
 
Programming Fundamentals lecture 5
Programming Fundamentals lecture 5Programming Fundamentals lecture 5
Programming Fundamentals lecture 5REHAN IJAZ
 
2 EPT 162 Lecture 2
2 EPT 162 Lecture 22 EPT 162 Lecture 2
2 EPT 162 Lecture 2Don Dooley
 
Compiler Construction for DLX Processor
Compiler Construction for DLX Processor Compiler Construction for DLX Processor
Compiler Construction for DLX Processor Soham Kulkarni
 
C Language (All Concept)
C Language (All Concept)C Language (All Concept)
C Language (All Concept)sachindane
 
2.overview of c#
2.overview of c#2.overview of c#
2.overview of c#Raghu nath
 

Ähnlich wie Oop lec 1 (20)

Complete C++ programming Language Course
Complete C++ programming Language CourseComplete C++ programming Language Course
Complete C++ programming Language Course
 
Datastructure notes
Datastructure notesDatastructure notes
Datastructure notes
 
Programming in C
Programming in CProgramming in C
Programming in C
 
Fundamentals of computer programming by Dr. A. Charan Kumari
Fundamentals of computer programming by Dr. A. Charan KumariFundamentals of computer programming by Dr. A. Charan Kumari
Fundamentals of computer programming by Dr. A. Charan Kumari
 
Introduction%20C.pptx
Introduction%20C.pptxIntroduction%20C.pptx
Introduction%20C.pptx
 
VIT351 Software Development VI Unit1
VIT351 Software Development VI Unit1VIT351 Software Development VI Unit1
VIT351 Software Development VI Unit1
 
C decision making and looping.
C decision making and looping.C decision making and looping.
C decision making and looping.
 
C programming
C programmingC programming
C programming
 
C programming
C programmingC programming
C programming
 
Basic of C Programming | 2022 Updated | By Shamsul H. Ansari
Basic of C Programming | 2022 Updated | By Shamsul H. AnsariBasic of C Programming | 2022 Updated | By Shamsul H. Ansari
Basic of C Programming | 2022 Updated | By Shamsul H. Ansari
 
UNIT-II CP DOC.docx
UNIT-II CP DOC.docxUNIT-II CP DOC.docx
UNIT-II CP DOC.docx
 
C++ programming language basic to advance level
C++ programming language basic to advance levelC++ programming language basic to advance level
C++ programming language basic to advance level
 
Python_UNIT-I.pptx
Python_UNIT-I.pptxPython_UNIT-I.pptx
Python_UNIT-I.pptx
 
chapter-2.ppt
chapter-2.pptchapter-2.ppt
chapter-2.ppt
 
Programming Fundamentals lecture 5
Programming Fundamentals lecture 5Programming Fundamentals lecture 5
Programming Fundamentals lecture 5
 
Unit 1
Unit 1Unit 1
Unit 1
 
2 EPT 162 Lecture 2
2 EPT 162 Lecture 22 EPT 162 Lecture 2
2 EPT 162 Lecture 2
 
Compiler Construction for DLX Processor
Compiler Construction for DLX Processor Compiler Construction for DLX Processor
Compiler Construction for DLX Processor
 
C Language (All Concept)
C Language (All Concept)C Language (All Concept)
C Language (All Concept)
 
2.overview of c#
2.overview of c#2.overview of c#
2.overview of c#
 

Mehr von Asfand Hassan

Course outline [csc241 object oriented programming]
Course outline [csc241 object oriented programming]Course outline [csc241 object oriented programming]
Course outline [csc241 object oriented programming]Asfand Hassan
 
Oop lec 3(structures)
Oop lec 3(structures)Oop lec 3(structures)
Oop lec 3(structures)Asfand Hassan
 
Oop lec 4(oop design, style, characteristics)
Oop lec 4(oop design, style, characteristics)Oop lec 4(oop design, style, characteristics)
Oop lec 4(oop design, style, characteristics)Asfand Hassan
 
Course outline [csc241 object oriented programming]
Course outline [csc241 object oriented programming]Course outline [csc241 object oriented programming]
Course outline [csc241 object oriented programming]Asfand Hassan
 
Oop lec 5-(class objects, constructor & destructor)
Oop lec 5-(class objects, constructor & destructor)Oop lec 5-(class objects, constructor & destructor)
Oop lec 5-(class objects, constructor & destructor)Asfand Hassan
 

Mehr von Asfand Hassan (11)

Chap5java5th
Chap5java5thChap5java5th
Chap5java5th
 
Chap6java5th
Chap6java5thChap6java5th
Chap6java5th
 
Chap4java5th
Chap4java5thChap4java5th
Chap4java5th
 
Chap3java5th
Chap3java5thChap3java5th
Chap3java5th
 
Chap2java5th
Chap2java5thChap2java5th
Chap2java5th
 
Chap1java5th
Chap1java5thChap1java5th
Chap1java5th
 
Course outline [csc241 object oriented programming]
Course outline [csc241 object oriented programming]Course outline [csc241 object oriented programming]
Course outline [csc241 object oriented programming]
 
Oop lec 3(structures)
Oop lec 3(structures)Oop lec 3(structures)
Oop lec 3(structures)
 
Oop lec 4(oop design, style, characteristics)
Oop lec 4(oop design, style, characteristics)Oop lec 4(oop design, style, characteristics)
Oop lec 4(oop design, style, characteristics)
 
Course outline [csc241 object oriented programming]
Course outline [csc241 object oriented programming]Course outline [csc241 object oriented programming]
Course outline [csc241 object oriented programming]
 
Oop lec 5-(class objects, constructor & destructor)
Oop lec 5-(class objects, constructor & destructor)Oop lec 5-(class objects, constructor & destructor)
Oop lec 5-(class objects, constructor & destructor)
 

Último

Metabolism , Metabolic Fate& disorders of cholesterol.pptx
Metabolism , Metabolic Fate& disorders of cholesterol.pptxMetabolism , Metabolic Fate& disorders of cholesterol.pptx
Metabolism , Metabolic Fate& disorders of cholesterol.pptxDr. Santhosh Kumar. N
 
Arti Languages Pre Seed Send Ahead Pitchdeck 2024.pdf
Arti Languages Pre Seed Send Ahead Pitchdeck 2024.pdfArti Languages Pre Seed Send Ahead Pitchdeck 2024.pdf
Arti Languages Pre Seed Send Ahead Pitchdeck 2024.pdfwill854175
 
Alamkara theory by Bhamaha Indian Poetics (1).pptx
Alamkara theory by Bhamaha Indian Poetics (1).pptxAlamkara theory by Bhamaha Indian Poetics (1).pptx
Alamkara theory by Bhamaha Indian Poetics (1).pptxDhatriParmar
 
Metabolism of lipoproteins & its disorders(Chylomicron & VLDL & LDL).pptx
Metabolism of  lipoproteins & its disorders(Chylomicron & VLDL & LDL).pptxMetabolism of  lipoproteins & its disorders(Chylomicron & VLDL & LDL).pptx
Metabolism of lipoproteins & its disorders(Chylomicron & VLDL & LDL).pptxDr. Santhosh Kumar. N
 
How to Customise Quotation's Appearance Using PDF Quote Builder in Odoo 17
How to Customise Quotation's Appearance Using PDF Quote Builder in Odoo 17How to Customise Quotation's Appearance Using PDF Quote Builder in Odoo 17
How to Customise Quotation's Appearance Using PDF Quote Builder in Odoo 17Celine George
 
BÀI TẬP BỔ TRỢ TIẾNG ANH 11 THEO ĐƠN VỊ BÀI HỌC - CẢ NĂM - CÓ FILE NGHE (FRIE...
BÀI TẬP BỔ TRỢ TIẾNG ANH 11 THEO ĐƠN VỊ BÀI HỌC - CẢ NĂM - CÓ FILE NGHE (FRIE...BÀI TẬP BỔ TRỢ TIẾNG ANH 11 THEO ĐƠN VỊ BÀI HỌC - CẢ NĂM - CÓ FILE NGHE (FRIE...
BÀI TẬP BỔ TRỢ TIẾNG ANH 11 THEO ĐƠN VỊ BÀI HỌC - CẢ NĂM - CÓ FILE NGHE (FRIE...Nguyen Thanh Tu Collection
 
BBA 205 BUSINESS ENVIRONMENT UNIT I.pptx
BBA 205 BUSINESS ENVIRONMENT UNIT I.pptxBBA 205 BUSINESS ENVIRONMENT UNIT I.pptx
BBA 205 BUSINESS ENVIRONMENT UNIT I.pptxProf. Kanchan Kumari
 
2024 March 11, Telehealth Billing- Current Telehealth CPT Codes & Telehealth ...
2024 March 11, Telehealth Billing- Current Telehealth CPT Codes & Telehealth ...2024 March 11, Telehealth Billing- Current Telehealth CPT Codes & Telehealth ...
2024 March 11, Telehealth Billing- Current Telehealth CPT Codes & Telehealth ...Marlene Maheu
 
BÀI TẬP BỔ TRỢ TIẾNG ANH 11 THEO ĐƠN VỊ BÀI HỌC - CẢ NĂM - CÓ FILE NGHE (GLOB...
BÀI TẬP BỔ TRỢ TIẾNG ANH 11 THEO ĐƠN VỊ BÀI HỌC - CẢ NĂM - CÓ FILE NGHE (GLOB...BÀI TẬP BỔ TRỢ TIẾNG ANH 11 THEO ĐƠN VỊ BÀI HỌC - CẢ NĂM - CÓ FILE NGHE (GLOB...
BÀI TẬP BỔ TRỢ TIẾNG ANH 11 THEO ĐƠN VỊ BÀI HỌC - CẢ NĂM - CÓ FILE NGHE (GLOB...Nguyen Thanh Tu Collection
 
BBA 205 BE UNIT 2 economic systems prof dr kanchan.pptx
BBA 205 BE UNIT 2 economic systems prof dr kanchan.pptxBBA 205 BE UNIT 2 economic systems prof dr kanchan.pptx
BBA 205 BE UNIT 2 economic systems prof dr kanchan.pptxProf. Kanchan Kumari
 
Certification Study Group - Professional ML Engineer Session 3 (Machine Learn...
Certification Study Group - Professional ML Engineer Session 3 (Machine Learn...Certification Study Group - Professional ML Engineer Session 3 (Machine Learn...
Certification Study Group - Professional ML Engineer Session 3 (Machine Learn...gdgsurrey
 
3.14.24 The Selma March and the Voting Rights Act.pptx
3.14.24 The Selma March and the Voting Rights Act.pptx3.14.24 The Selma March and the Voting Rights Act.pptx
3.14.24 The Selma March and the Voting Rights Act.pptxmary850239
 
3.12.24 The Social Construction of Gender.pptx
3.12.24 The Social Construction of Gender.pptx3.12.24 The Social Construction of Gender.pptx
3.12.24 The Social Construction of Gender.pptxmary850239
 
LEAD6001 - Introduction to Advanced Stud
LEAD6001 - Introduction to Advanced StudLEAD6001 - Introduction to Advanced Stud
LEAD6001 - Introduction to Advanced StudDr. Bruce A. Johnson
 
30-de-thi-vao-lop-10-mon-tieng-anh-co-dap-an.doc
30-de-thi-vao-lop-10-mon-tieng-anh-co-dap-an.doc30-de-thi-vao-lop-10-mon-tieng-anh-co-dap-an.doc
30-de-thi-vao-lop-10-mon-tieng-anh-co-dap-an.docdieu18
 
ASTRINGENTS.pdf Pharmacognosy chapter 5 diploma in Pharmacy
ASTRINGENTS.pdf Pharmacognosy chapter 5 diploma in PharmacyASTRINGENTS.pdf Pharmacognosy chapter 5 diploma in Pharmacy
ASTRINGENTS.pdf Pharmacognosy chapter 5 diploma in PharmacySumit Tiwari
 
UNIT I Design Thinking and Explore.pptx
UNIT I  Design Thinking and Explore.pptxUNIT I  Design Thinking and Explore.pptx
UNIT I Design Thinking and Explore.pptxGOWSIKRAJA PALANISAMY
 
LEAD5623 The Economics of Community Coll
LEAD5623 The Economics of Community CollLEAD5623 The Economics of Community Coll
LEAD5623 The Economics of Community CollDr. Bruce A. Johnson
 
LEAD6001 - Introduction to Advanced Stud
LEAD6001 - Introduction to Advanced StudLEAD6001 - Introduction to Advanced Stud
LEAD6001 - Introduction to Advanced StudDr. Bruce A. Johnson
 

Último (20)

Metabolism , Metabolic Fate& disorders of cholesterol.pptx
Metabolism , Metabolic Fate& disorders of cholesterol.pptxMetabolism , Metabolic Fate& disorders of cholesterol.pptx
Metabolism , Metabolic Fate& disorders of cholesterol.pptx
 
Arti Languages Pre Seed Send Ahead Pitchdeck 2024.pdf
Arti Languages Pre Seed Send Ahead Pitchdeck 2024.pdfArti Languages Pre Seed Send Ahead Pitchdeck 2024.pdf
Arti Languages Pre Seed Send Ahead Pitchdeck 2024.pdf
 
Alamkara theory by Bhamaha Indian Poetics (1).pptx
Alamkara theory by Bhamaha Indian Poetics (1).pptxAlamkara theory by Bhamaha Indian Poetics (1).pptx
Alamkara theory by Bhamaha Indian Poetics (1).pptx
 
Metabolism of lipoproteins & its disorders(Chylomicron & VLDL & LDL).pptx
Metabolism of  lipoproteins & its disorders(Chylomicron & VLDL & LDL).pptxMetabolism of  lipoproteins & its disorders(Chylomicron & VLDL & LDL).pptx
Metabolism of lipoproteins & its disorders(Chylomicron & VLDL & LDL).pptx
 
How to Customise Quotation's Appearance Using PDF Quote Builder in Odoo 17
How to Customise Quotation's Appearance Using PDF Quote Builder in Odoo 17How to Customise Quotation's Appearance Using PDF Quote Builder in Odoo 17
How to Customise Quotation's Appearance Using PDF Quote Builder in Odoo 17
 
BÀI TẬP BỔ TRỢ TIẾNG ANH 11 THEO ĐƠN VỊ BÀI HỌC - CẢ NĂM - CÓ FILE NGHE (FRIE...
BÀI TẬP BỔ TRỢ TIẾNG ANH 11 THEO ĐƠN VỊ BÀI HỌC - CẢ NĂM - CÓ FILE NGHE (FRIE...BÀI TẬP BỔ TRỢ TIẾNG ANH 11 THEO ĐƠN VỊ BÀI HỌC - CẢ NĂM - CÓ FILE NGHE (FRIE...
BÀI TẬP BỔ TRỢ TIẾNG ANH 11 THEO ĐƠN VỊ BÀI HỌC - CẢ NĂM - CÓ FILE NGHE (FRIE...
 
BBA 205 BUSINESS ENVIRONMENT UNIT I.pptx
BBA 205 BUSINESS ENVIRONMENT UNIT I.pptxBBA 205 BUSINESS ENVIRONMENT UNIT I.pptx
BBA 205 BUSINESS ENVIRONMENT UNIT I.pptx
 
2024 March 11, Telehealth Billing- Current Telehealth CPT Codes & Telehealth ...
2024 March 11, Telehealth Billing- Current Telehealth CPT Codes & Telehealth ...2024 March 11, Telehealth Billing- Current Telehealth CPT Codes & Telehealth ...
2024 March 11, Telehealth Billing- Current Telehealth CPT Codes & Telehealth ...
 
BÀI TẬP BỔ TRỢ TIẾNG ANH 11 THEO ĐƠN VỊ BÀI HỌC - CẢ NĂM - CÓ FILE NGHE (GLOB...
BÀI TẬP BỔ TRỢ TIẾNG ANH 11 THEO ĐƠN VỊ BÀI HỌC - CẢ NĂM - CÓ FILE NGHE (GLOB...BÀI TẬP BỔ TRỢ TIẾNG ANH 11 THEO ĐƠN VỊ BÀI HỌC - CẢ NĂM - CÓ FILE NGHE (GLOB...
BÀI TẬP BỔ TRỢ TIẾNG ANH 11 THEO ĐƠN VỊ BÀI HỌC - CẢ NĂM - CÓ FILE NGHE (GLOB...
 
BBA 205 BE UNIT 2 economic systems prof dr kanchan.pptx
BBA 205 BE UNIT 2 economic systems prof dr kanchan.pptxBBA 205 BE UNIT 2 economic systems prof dr kanchan.pptx
BBA 205 BE UNIT 2 economic systems prof dr kanchan.pptx
 
Problems on Mean,Mode,Median Standard Deviation
Problems on Mean,Mode,Median Standard DeviationProblems on Mean,Mode,Median Standard Deviation
Problems on Mean,Mode,Median Standard Deviation
 
Certification Study Group - Professional ML Engineer Session 3 (Machine Learn...
Certification Study Group - Professional ML Engineer Session 3 (Machine Learn...Certification Study Group - Professional ML Engineer Session 3 (Machine Learn...
Certification Study Group - Professional ML Engineer Session 3 (Machine Learn...
 
3.14.24 The Selma March and the Voting Rights Act.pptx
3.14.24 The Selma March and the Voting Rights Act.pptx3.14.24 The Selma March and the Voting Rights Act.pptx
3.14.24 The Selma March and the Voting Rights Act.pptx
 
3.12.24 The Social Construction of Gender.pptx
3.12.24 The Social Construction of Gender.pptx3.12.24 The Social Construction of Gender.pptx
3.12.24 The Social Construction of Gender.pptx
 
LEAD6001 - Introduction to Advanced Stud
LEAD6001 - Introduction to Advanced StudLEAD6001 - Introduction to Advanced Stud
LEAD6001 - Introduction to Advanced Stud
 
30-de-thi-vao-lop-10-mon-tieng-anh-co-dap-an.doc
30-de-thi-vao-lop-10-mon-tieng-anh-co-dap-an.doc30-de-thi-vao-lop-10-mon-tieng-anh-co-dap-an.doc
30-de-thi-vao-lop-10-mon-tieng-anh-co-dap-an.doc
 
ASTRINGENTS.pdf Pharmacognosy chapter 5 diploma in Pharmacy
ASTRINGENTS.pdf Pharmacognosy chapter 5 diploma in PharmacyASTRINGENTS.pdf Pharmacognosy chapter 5 diploma in Pharmacy
ASTRINGENTS.pdf Pharmacognosy chapter 5 diploma in Pharmacy
 
UNIT I Design Thinking and Explore.pptx
UNIT I  Design Thinking and Explore.pptxUNIT I  Design Thinking and Explore.pptx
UNIT I Design Thinking and Explore.pptx
 
LEAD5623 The Economics of Community Coll
LEAD5623 The Economics of Community CollLEAD5623 The Economics of Community Coll
LEAD5623 The Economics of Community Coll
 
LEAD6001 - Introduction to Advanced Stud
LEAD6001 - Introduction to Advanced StudLEAD6001 - Introduction to Advanced Stud
LEAD6001 - Introduction to Advanced Stud
 

Oop lec 1

  • 1. Review of Basic Programming Concepts Lecture No 1 COMSATS Institute of Information Technology 1 Object Oriented Programming
  • 2. Basics of Typical C Program Development Environment A program development environment The language C Standard Library 2 Object Oriented Programming
  • 3. Six phases to be executed Edit Preprocessor Compile Link Load Execute 3 Object Oriented Programming
  • 4. Stages of compilation Preprocessing Performed by a program called the preprocessor Modifies the source code (in RAM) according to preprocessor directives (preprocessor commands) embedded in the source code Strips comments and white space from the code 4 Object Oriented Programming
  • 5. Compilation Performed by a program called the compiler Translates the preprocessor-modified source code into object code (machine code) Checks for syntax errors and warnings o If any compiler errors are received, no object code file will be generated. o An object code file will be generated if only warnings, not errors, are received. 5 Object Oriented Programming
  • 6. Linking Combines the program object code with other object code to produce the executable file. The other object code can come from the Run-Time Library, other libraries, or object files that you have created. Saves the executable code to a disk file o If any linker errors are received, no executable file will be generated. 6 Object Oriented Programming
  • 7. Simple c program /* Filename: product.c Description: This program prompts the user for two integer values then displays their product. */ #include <stdio.h> int main( void ) { int value1, value2, product ; printf(“Enter two integer values: “) ; scanf(“%d%d”, &value1, &value2) ; product = value1 * value2 ; printf(“Product = %dn”, product) ; return 0 ; } 7 Object Oriented Programming
  • 8. Anatomy of c program program header comment preprocessor directives (if any) int main ( void ) { statement(s) return 0 ; } 8 Object Oriented Programming
  • 9. A comment is descriptive text used to help a reader of the program understand its content. Lines that begin with a # are called preprocessor directives (commands). Every program must have a function called main. This is where program execution begins. A left brace (curly bracket) -- { -- begins the body of every function. A corresponding right brace -- } -- ends the function body. 9 Object Oriented Programming
  • 10. int value1, value2, product; Declaration of variables  Variables: locations in memory where a value can be stored int means the variables can hold integers (-1, 3, 0, 47) Variable names (identifiers)  value1, value2, product  Identifiers: consist of letters, digits (cannot begin with a digit) and underscores( _ )  Case sensitive Declarations appear before executable statements  If an executable statement references and undeclared variable it will produce a syntax (compiler) error 10 Object Oriented Programming
  • 11. scanf("%d%d", &value1,&value2); Obtains values from the user  scanf uses standard input (usually keyboard) This scanf statement has two arguments  %d - indicates data should be a decimal integer  &value1 - location in memory to store variable When executing the program the user responds to the scanf statement by typing in a number, then pressing the enter (return) key 11 Object Oriented Programming
  • 12. = (assignment operator) Assigns a value to a variable Is a binary operator (has two operands) product = value1 * value2; Variable receiving value on left printf( “Product is %dn", product); Similar to scanf  %d means decimal integer will be printed  product specifies what integer will be printed 12 Object Oriented Programming
  • 13. Arithmetic Arithmetic operators: C operation Addition Subtraction Multiplication Division Modulus Arithmetic operator + * / % Algebraic expression f+7 p–c bm x/y r mod s Rules of operator precedence: Operator(s) () f p b x r + * / % 7 c m y s Order of evaluation (precedence) Evaluated first. If the parentheses are nested, the expression in the innermost pair is evaluated first. If there are several pairs of parentheses “on the same level” (i.e., not nested), they are evaluated left to right. Multiplication,Divi Evaluated second. If there are several, they are *, /, or % sion, Modulus evaluated left to right. Addition Evaluated last. If there are several, they are + or Subtraction evaluated left to right. Object Oriented Programming 13 Operation(s) Parentheses C expression
  • 14. Decision Making: Equality and Relational Operators  Executable statements  Perform actions (calculations, input/output of data)  Perform decisions  May want to print "pass" or "fail" given the value of a test grade  if control structure  Simple version in this section, more detail later  If a condition is true, then the body of the if statement executed  0 is false, non-zero is true  Control always resumes after the if structure  Keywords  Special words reserved for C  Cannot be used as identifiers or variable names 14 Object Oriented Programming
  • 15. Decision Making: Equality and Relational Operators Standard algebraic equality operator or relational operator C equality or relational operator Example of C Meaning of C condition condition == != x == y x is equal to y x != y x is not equal to y x > y x is greater than y < > < x < y x is less than y >= >= x >= y x is greater than or equal to y <= <= x <= y x is less than or equal to y Equality Operators = not = Relational Operators > 15 Object Oriented Programming
  • 16. Control Structures Control Flow In C, three ways to specify sequence of statement execution Sequential Execution Conditional Execution Iterative Execution 16 Object Oriented Programming
  • 17. Conditional Execution One-way selection or if Two-way selection or if-else Multiple Selection or nested if 17 Object Oriented Programming
  • 18. One-way selection or if If(expression) statement1; If(x>10) y=z/x; y=z*x; If(x>y) printf(“the largest is %d”,x); 18 Object Oriented Programming
  • 19. Two-way selection or if-else If(expression) statement1; else statement2; If(x>y) printf(“the largest is %d”,x); else printf(“the largest is %d”,y); 19 Object Oriented Programming
  • 20. Multiple Selection or nested if If(condition1) { if(condition2) statement1; } else statement2; 20 Object Oriented Programming
  • 21. Iterative Execution The while statement The for statement The do-while statement 21 Object Oriented Programming
  • 22. The while statement  While(expression) statement1; #include<stdio.h> int main() { Int k, num, maximum=10; k=1; while(k<=maximum) { scanf(“%d”, &num); printf(“%4d”, num); k++; } return 0; } 22 Object Oriented Programming
  • 23. The for statement for(expression1;expression2;expression3) statement1; expression1: initial value expression2: boolean expression expression3: update of expression 23 Object Oriented Programming
  • 24. Example #include<stdio.h> int main() { int sum, n, i; sum = 0; scanf(“%d”, &n); for(i=1; i<=n; i++) sum = sum + i; printf(“Sum=%dn”,sum); return 0; } 24 Object Oriented Programming
  • 26. Example #include<stdio.h> int main() { int sum, num; sum = 0; num=1; do { sum = sum + num; num++; } while(num <= 10); printf(“Sum=%dn”,sum); return 0; } 26 Object Oriented Programming
  • 28. Example #include<stdio.h> int main() { int n; printf(“Enter an integer valuen” ); scanf(“%d”, &n); switch(n) { case 1: printf(“The value is 1n”); break; case 2: printf(“The value is 2n”); break; default: printf(“The value is neither 1 nor 2n”); } return 0; } 28 Object Oriented Programming
  • 29. Functions An independent set of statements for performing some special tasks Attributes Name of function (user-defined) Parameters Variable declaration (if any) The body of function 29 Object Oriented Programming
  • 30. Divisions of Function Prototype int largest(int x, int y); Definition Head function itself Invocation large = largest (x, y); 30 Object Oriented Programming
  • 31. Types of Function  System-supplied functions To instruct system to accomplish specific operations Saves programmers time to writing own functions Completely debugged, efficient and always produce precise output Reduce source code printf(“%d”, x);  User-defined functions Defined by programmer as part of source code Result-type user-defined-name(parameters) 31 Object Oriented Programming
  • 32. User-defined function #include<stdio.h> int retlarge(int num1, int num2); int main() { int num1, num2, large; scanf(“%d%d”, &num1, &num2) ; printf(“%d %dn”, num1, num2) ; large = retlarge(num1, num2); printf(“large = %dn”, large); return 0; } int retlarge(int x, int y) { if (x>y) return(x); else return(y); } 32 Object Oriented Programming
  • 33. Methods for transmitting parameters Passing by value treated as local variables the initial value is obtained by copying the values of associated actual parameters Passing by location passing by address or reference linking actual parameters to formal parameters by passing address of actual parameters from the calling program to called program 33 Object Oriented Programming
  • 34. Arrays  Group of elements of same type.  Collection of similar data type stored in contiguous memory location.  To refer to an element, specify Name of array (Note that all elements of this array have the same name, c) c[0] -45 c[1] 6 c[2] 0 c[3] 72 c[4] 1543 c[5] -89 arrayname[ position number ] c[6] 0  First element at position 0  n element array named c:  c[ 0 ], c[ 1 ]...c[ n – 1 ] c[7] 62 c[8] -3 c[9] 1  Array name  Position number  Format: c[10] c[11] 34 Object Oriented Programming 6453 78 Position number of the element within array c
  • 35. Declaring Arrays  When declaring arrays, specify Name Type of array Number of elements arrayType arrayName[ numberOfElements ]; Examples: int c[ 10 ]; float myArray[ 3284 ];  Declaring multiple arrays of same type Example: int b[ 100 ], x[ 27 ]; 35 Object Oriented Programming
  • 36.  Initializers int n[ 5 ] = { 1, 2, 3, 4, 5 }; If not enough initializers, rightmost elements become 0 int n[ 5 ] = { 0 }  All elements 0 If too many a syntax error is produced syntax error C arrays have no bounds checking  If size omitted, initializers determine it int n[ ] = { 1, 2, 3, 4, 5 }; 5 initializers, therefore 5 element array 36 Object Oriented Programming
  • 37.  Character arrays  String “first” is really a static array of characters  Character arrays can be initialized using string literals char string1[] = "first";  Null character '0' terminates strings  string1 actually has 6 elements  It is equivalent to char string1[] = { 'f', 'i', 'r', 's', 't', '0' };  Can access individual characters string1[ 3 ] is character ‘s’  Array name is address of array, so & not needed for scanf scanf( "%s", string2 );  Reads characters until whitespace encountered  Can write beyond end of array, be careful 37 Object Oriented Programming
  • 38. Array Subscripting Formula Address of i-th element = address of 0-th element + i * (size of type) Assuming declaration int intarr[10]; Assuming address of array intarr is located at address 10 in memory Accessing element intarr[5] can be calculated by formula: Address of i-th element = 10 + 5 * 2 = 20 38 Object Oriented Programming
  • 39. Pointers Pointers are variables that contain memory addresses as their values. A variable name directly references a value. A pointer indirectly references a value. Referencing a value through a pointer is called indirection. A pointer variable must be declared before it can be used. 39 Object Oriented Programming
  • 40.  Memory can be conceptualized as a linear set of data locations.  Variables reference the contents of a locations  Pointers have a value of the address of a given location  A declaration int intval=10; Then int ptr can be set as int *ptr; Pointing to intval by ptr = &intval; Address of intval assigned to ptr, not contents! 40 Object Oriented Programming
  • 41. & and *  When is & used?  When is * used?  & -- "address operator" which gives or produces the memory address of a data variable  * -- "dereferencing operator" which provides the contents in the memory location specified by a pointer 41 Object Oriented Programming
  • 42. Pointers and Function Pointers can be used to pass addresses of variables to called functions, thus allowing the called function to alter the values stored there. If instead of passing the values of the variables to the called function, we pass their addresses, so that the called function can change the values stored in the calling routine. This is known as "call by reference" since we are referencing the variables. 42 Object Oriented Programming
  • 43. Passing pointers to function #include <stdio.h> void exchange ( int *a, int *b ) ; int main ( ) { int a = 5, b = 6; printf("a=%d b=%dn",a,b) ; exchange (&a, &b) ; printf("a=%d b=%dn",a,b) ; return 0 ; } 43 Object Oriented Programming
  • 44. void exchange( int *a, int *b ) { int temp; temp= *a; *a= *b; *b = temp ; printf ("a=%d b=%dn", *a, *b); } Results: a=5 b=6 a=6 b=5 a=6 b=5 44 Object Oriented Programming