SlideShare a Scribd company logo
Programming in C –Call By
Prof. A. Syed Mustafa, HKBK College of Engineering
Program to find area of a circle using #define.
#include<stdio.h>
#define PI 3.1412
int main()
{
int radius; float area;
printf("Enter the radius: ");
scanf("%d", &radius);
area=PI*radius*radius;
printf("Area=%.2f",area);
return 0;
}
Use of #if, #elif, #else and #endif :
The preprocessor directives #if, #elif, #else and #endif allows to
conditionally compile a block of code based on predefined symbols.
#include<stdio.h>
#define MAX 100
void main( )
{
#if (MAX)
printf("MAX is defined");
#else
printf ("MAX is not defined");
#endif
}
Preprocessor Directive / Macros
The C preprocessor [CPP] is a macro processor that is used
automatically by the C compiler to transform programmer defined
programs before actual compilation takes place. It is called a macro
processor because it allows the user to define macros, which are short
abbreviations for longer constructs.
It instructs the compiler to do required pre-processing before the
actual compilation. All preprocessor directives begin with the #
symbol (known as pound or hash).
List of pre-processor directives:
1. #include: This is used insert a particular header from another file.
2. #define, #undef : These are used to define and un-define
conditional compilation symbols.
3. #if, #elif, #else, #endif : These are used to conditionally skip
sections of source code.
Example:
#include “demo.h”
 tells CPP to get demo.h from the local directory and add the
content to the current source file.
#define PI 3.1412 /* defines symbolic constant */
 This directive tells the CPP to replace symbolic constant pi
with 3.1412.
#define SIZE 5 /* SIZE will be replaced with 5 */
Programming in C –Call By
Prof. A. Syed Mustafa, HKBK College of Engineering
MEMORY ALLOCATION FUNCTIONS
1. Static Memory Allocation:
Memory space allocated from stack at compile time for variables
declared in the program is fixed, it cannot be altered during
execution-time. This is called static memory allocation.
Example: int a[5]; float d;
2. Dynamic Memory Allocation
It is the process of allocating memory-space during execution-time
i.e. run time from Heap. If there is an unpredictable storage
requirement, then the dynamic allocation technique is used.
This allocation technique uses predefined functions to allocate and
release memory for data during execution-time.
There are 4 library functions for dynamic memory allocation:
malloc( ), calloc( ), free( ), realloc( )
These library functions are defined under "stdlib.h"
1. malloc( ) -memory allocation
This function is used to allocate the required memory-space
during execution-time.
The syntax is shown below:
data_type *p;
p=(data_type*)malloc(size);
Here p is pointer variable.
data_type can be int, float or char. size is number of bytes to be
allocated.If memory is successfully allocated, then address of the first
byte of allocated space is returned. If memory allocation fails, then
NULL is returned.
For ex: int *ptr;
ptr=(int*)malloc(100*sizeof(int));
The above code will allocate 200 bytes assuming sizeof(int)=2 bytes.
2. calloc( ) - contiguous allocation
This function is used to allocate the required memory-size during
execution-time and at the same time, automatically initialize
memory with 0's.
syntax :
data_type *p;
p=(data_type*)calloc(n,size);
Ex:
p=(int*)calloc(25,sizeof(int));
3. free( )
Dynamically allocated memory with either calloc( ) or malloc( ) can
be deallocated using free( ) explicitly to release space.
syntax:
free(ptr);
4. realloc() -reallocation
If the previously allocated memory is insufficient or more than
sufficient. Then, we can change memory-size previously allocated
using realloc().
The syntax is shown below:
ptr=(data_type*)realloc(ptr,newsize);
void main( )
{ int i;
int *a= (int *)malloc(10);
for(i=0;i<5;i++)
*(a+i)=i+10;
for(i=0;i<5;i++)
printf(“%dt”,*(a+i)10;
}
Output: 10 11 12 13 14
Programming in C –Call By
Prof. A. Syed Mustafa, HKBK College of Engineering
Pointers
A Pointer is just an address of the data stored in memory.
A pointer is a variable whose value is the address of
another variable, i.e., direct address of the memory
location.
Syntax: <variable_type> *<name>=&variable; eg:- int *a=&b;
‘*’ used to declare a pointer variable and also used to retrieve the value
from the pointed memory location. ‘*’ is also called as derefence operator.
#include <stdio.h>
void main ()
{
int a = 20; /* actual variable declaration */
int *ip; /* pointer variable declaration */
ip = &a; /* store address of var in pointer variable*/
printf("Address of variable a is: %xn", &a );
/* address stored in pointer variable */
printf("Address stored in variable ip is: %xn", ip );
/* access the value using the pointer */
printf("Value of *ip variable: %dn", *ip );
}
Output:
Address of variable a is: bffd8b3c
Address stored in variable ip is: bffd8b3c
Value of *ip variable: 20
Actual Parameter
 The parameter’s value (or arguments) we provide while calling
a function is known as actual arguments.
 Parameter Written In Function Call is Called “Actual Parameter”
 Actual parameters are parameters as they appear in function calls.
 The actual value that is passed into the function by a caller.
Formal Parameter
 Formal parameters are parameters as they appear in function
declarations.
 the identifier used in a method to stand for the value that is passed
into the function by a caller.
 Parameter Written In Function Definition is Called “Formal Parameter”
 While declaring a function, the arguments list of parameters we
specify are known as formal parameters.
Example
Programming in C –Call By
Prof. A. Syed Mustafa, HKBK College of Engineering
CALL BY ADDRESS
The call to the function passes variable’s
address to the called function. The actual
arguments are not copied to the formal
arguments, the addresses of actual
arguments (or parameters) are passed to
the formal parameters. Hence any
operation performed by function on
formal arguments / parameters affects
actual parameters.
void swap(int *x, int *y)
{ int t=*x; *x=*y; *y=t;
}
void main( ) {
int a=5, b=10 ;
printf("Before swap: a=%d,b=%d",a,b);
swap(&a,&b); /*calling swap function*/
printf("After swap: a= %d,b=%d",a,b);
}
Output:
Before swap: a=5,b=10
After swap: a=10,b=5
Because variable declared ‘a’, ‘b’ in
main() is different from variable ‘x’, ’y’ in
swap(). Only variable names are
different but both a and x, b and y point
to the same memory address locations
respectively.
CALL BY REFERENCE
The call to the function passes base address to
the called function. The actual arguments are
not copied to the formal arguments, only
referencing is made. Hence any operation
performed by function on formal arguments /
parameters affects actual parameters.
void change(int b[ ])
{
b[0]=10; b[1]=20; b[2]=30;
}
void main( )
{
int a[3]={ 5, 15, 25 } ;
printf("BeforeChange:%d,%d,%d",a[0],a[1],a[2]);
change(a); /*calling swap function*/
printf("AfterChange:%d,%d,%d",a[0],a[1],a[2]);
}
Output:
BeforeChange: 5,15,25
AfterChange: 10,20,30
Because array variable declared ‘b’ in change() is
referencing/ pointing to array variable ‘a’ in
main(). Only variable name is different but
both are pointing / referencing to same
memory address locations.
CALL BY VALUE
The call to the function passes either the values
or the normal variables to the called function.
The actual arguments are copied to the formal
arguments, hence any operation performed by
function on arguments doesn’t affect actual
parameters.
void swap(int a, int b)
{
int t=a; a=b; b=t;
}
void main( )
{
int a=5, b=10 ;
printf("Before swap: a=%d,b=%d",a,b);
swap(a,b); /*calling swap function*/
printf("After swap: a= %d,b=%d",a,b);
}
Output:
Before swap: a=5,b=10
After swap: a=5,b=10
Because variable declared ‘a’, ‘b’ in main() is
different from variable ‘a’, ’b’ in swap(). Only
variable names are similar but their memory
address are different and stored in different
memory locations.
Programming in C –Call By
Prof. A. Syed Mustafa, HKBK College of Engineering
STACKS
• A stack is a special type of data structure where elements are inserted from one end and elements are deleted from the same
end.
• Using this approach, the Last element Inserted is the First element to be deleted Out, and hence, stack is also called LIFO data
structure.
• The various operations performed on stack:
Insert: An element is inserted from top end. Insertion operation is called push operation. Delete: An element is
deleted from top end. Deletion operation is called pop operation. Overflow: Check whether the stack is full or not.
Underflow: Check whether the stack is empty or not.
• This can be pictorially represented as shown below:
APPLICATIONS OF STACK
1) Conversion of expressions: The compiler converts the infix expressions into postfix expressions using stack.
2) Evaluation of expression: An arithmetic expression represented in the form of either postfix or prefix can be easily evaluated
using stack.
3) Recursion: A function which calls itself is called recursive function.
4) Other applications: To find whether the string is a palindrome, to check whether a given expression is valid or not.
Programming in C –Call By
Prof. A. Syed Mustafa, HKBK College of Engineering
PRIMITIVE AND NON-PRIMITIVE DATA TYPES
Data type specifies the type of data stored in a
variable. The data type can be classified into two
types: 1) Primitive data type and 2)Non-Primitive data
type
Primitive Data Type
• The primitive data types are the basic data types
that are available in most of the programming
languages.
• The primitive data types are used to represent single
values.
Integer: This is used to represent a number without
decimal point. Eg: int a=12;
Float: This is used to represent a number with
decimal point. Eg: float a=45.1; double b=67.3;
Character: This is used to represent single character
Eg: char ch=‘C’; char ch1= ‘a’;
Non Primitive Data Type
• The data types that are derived from primary data types
are known as non-Primitive data types.
• These datatypes are used to store group of values.
• The non-primitive data types are
Arrays, Structure
Stacks, Linked list
Queue, Binary tree

More Related Content

What's hot

Operators in C Programming
Operators in C ProgrammingOperators in C Programming
Operators in C Programming
programming9
 
Strings in C
Strings in CStrings in C
Strings in C
Kamal Acharya
 
Decision making statements in C programming
Decision making statements in C programmingDecision making statements in C programming
Decision making statements in C programming
Rabin BK
 
Presentation on c structures
Presentation on c   structures Presentation on c   structures
Presentation on c structures
topu93
 
Handling of character strings C programming
Handling of character strings C programmingHandling of character strings C programming
Handling of character strings C programming
Appili Vamsi Krishna
 
C pointer
C pointerC pointer
Preprocessor directives in c language
Preprocessor directives in c languagePreprocessor directives in c language
Preprocessor directives in c language
tanmaymodi4
 
User defined functions in C
User defined functions in CUser defined functions in C
User defined functions in C
Harendra Singh
 
Pointers C programming
Pointers  C programmingPointers  C programming
Pointers C programming
Appili Vamsi Krishna
 
Looping statement
Looping statementLooping statement
Looping statementilakkiya
 
Inline function in C++
Inline function in C++Inline function in C++
Inline function in C++
Jenish Patel
 
Control Flow Statements
Control Flow Statements Control Flow Statements
Control Flow Statements
Tarun Sharma
 
Function C programming
Function C programmingFunction C programming
Function C programming
Appili Vamsi Krishna
 
Pointers in C Programming
Pointers in C ProgrammingPointers in C Programming
Pointers in C Programming
Jasleen Kaur (Chandigarh University)
 
Scope rules : local and global variables
Scope rules : local and global variablesScope rules : local and global variables
Scope rules : local and global variables
sangrampatil81
 
C lecture 4 nested loops and jumping statements slideshare
C lecture 4 nested loops and jumping statements slideshareC lecture 4 nested loops and jumping statements slideshare
C lecture 4 nested loops and jumping statements slideshare
Gagan Deep
 

What's hot (20)

Operators in C Programming
Operators in C ProgrammingOperators in C Programming
Operators in C Programming
 
Strings in C
Strings in CStrings in C
Strings in C
 
Decision making statements in C programming
Decision making statements in C programmingDecision making statements in C programming
Decision making statements in C programming
 
Presentation on c structures
Presentation on c   structures Presentation on c   structures
Presentation on c structures
 
Function in C program
Function in C programFunction in C program
Function in C program
 
Handling of character strings C programming
Handling of character strings C programmingHandling of character strings C programming
Handling of character strings C programming
 
C pointer
C pointerC pointer
C pointer
 
File handling in c
File handling in cFile handling in c
File handling in c
 
Preprocessor directives in c language
Preprocessor directives in c languagePreprocessor directives in c language
Preprocessor directives in c language
 
User defined functions in C
User defined functions in CUser defined functions in C
User defined functions in C
 
Functions in c++
Functions in c++Functions in c++
Functions in c++
 
Pointers C programming
Pointers  C programmingPointers  C programming
Pointers C programming
 
Looping statement
Looping statementLooping statement
Looping statement
 
Inline function in C++
Inline function in C++Inline function in C++
Inline function in C++
 
Functions in C
Functions in CFunctions in C
Functions in C
 
Control Flow Statements
Control Flow Statements Control Flow Statements
Control Flow Statements
 
Function C programming
Function C programmingFunction C programming
Function C programming
 
Pointers in C Programming
Pointers in C ProgrammingPointers in C Programming
Pointers in C Programming
 
Scope rules : local and global variables
Scope rules : local and global variablesScope rules : local and global variables
Scope rules : local and global variables
 
C lecture 4 nested loops and jumping statements slideshare
C lecture 4 nested loops and jumping statements slideshareC lecture 4 nested loops and jumping statements slideshare
C lecture 4 nested loops and jumping statements slideshare
 

Viewers also liked

Call by value
Call by valueCall by value
Call by valueDharani G
 
e computer notes - Writing basic sql select statements
e computer notes - Writing basic sql select statementse computer notes - Writing basic sql select statements
e computer notes - Writing basic sql select statementsecomputernotes
 
e computer notes - Reference variables
e computer notes - Reference variablese computer notes - Reference variables
e computer notes - Reference variablesecomputernotes
 
e computer notes - Manipulating data
e computer notes - Manipulating datae computer notes - Manipulating data
e computer notes - Manipulating dataecomputernotes
 
All important c programby makhan kumbhkar
All important c programby makhan kumbhkarAll important c programby makhan kumbhkar
All important c programby makhan kumbhkar
sandeep kumbhkar
 
C programming language
C programming languageC programming language
C programming language
Abin Rimal
 
Palindrome number program in c
Palindrome number program in cPalindrome number program in c
Palindrome number program in c
mohdshanu
 
Functions
FunctionsFunctions
Functions
Online
 
Module 03 File Handling in C
Module 03 File Handling in CModule 03 File Handling in C
Module 03 File Handling in C
Tushar B Kute
 
Structure c
Structure cStructure c
Structure c
thirumalaikumar3
 
File handling in c
File handling in c File handling in c
File handling in c
Vikash Dhal
 
UNIT 10. Files and file handling in C
UNIT 10. Files and file handling in CUNIT 10. Files and file handling in C
UNIT 10. Files and file handling in C
Ashim Lamichhane
 
C programs
C programsC programs
C programsMinu S
 
C Programming
C ProgrammingC Programming
C Programming
Sumant Diwakar
 
File handling in c
File handling in cFile handling in c
File handling in c
aakanksha s
 
C++ programming function
C++ programming functionC++ programming function
C++ programming function
Vishalini Mugunen
 
Structure in c
Structure in cStructure in c
Structure in c
Prabhu Govind
 

Viewers also liked (20)

Parameter passing to_functions_in_c
Parameter passing to_functions_in_cParameter passing to_functions_in_c
Parameter passing to_functions_in_c
 
Call by value
Call by valueCall by value
Call by value
 
e computer notes - Writing basic sql select statements
e computer notes - Writing basic sql select statementse computer notes - Writing basic sql select statements
e computer notes - Writing basic sql select statements
 
e computer notes - Reference variables
e computer notes - Reference variablese computer notes - Reference variables
e computer notes - Reference variables
 
e computer notes - Manipulating data
e computer notes - Manipulating datae computer notes - Manipulating data
e computer notes - Manipulating data
 
week-20x
week-20xweek-20x
week-20x
 
All important c programby makhan kumbhkar
All important c programby makhan kumbhkarAll important c programby makhan kumbhkar
All important c programby makhan kumbhkar
 
C programming language
C programming languageC programming language
C programming language
 
Palindrome number program in c
Palindrome number program in cPalindrome number program in c
Palindrome number program in c
 
Functions
FunctionsFunctions
Functions
 
Module 03 File Handling in C
Module 03 File Handling in CModule 03 File Handling in C
Module 03 File Handling in C
 
C lab-programs
C lab-programsC lab-programs
C lab-programs
 
Structure c
Structure cStructure c
Structure c
 
File handling in c
File handling in c File handling in c
File handling in c
 
UNIT 10. Files and file handling in C
UNIT 10. Files and file handling in CUNIT 10. Files and file handling in C
UNIT 10. Files and file handling in C
 
C programs
C programsC programs
C programs
 
C Programming
C ProgrammingC Programming
C Programming
 
File handling in c
File handling in cFile handling in c
File handling in c
 
C++ programming function
C++ programming functionC++ programming function
C++ programming function
 
Structure in c
Structure in cStructure in c
Structure in c
 

Similar to Pointers and call by value, reference, address in C

Preprocessor directives
Preprocessor directivesPreprocessor directives
Preprocessor directives
Vikash Dhal
 
Presentation on Function in C Programming
Presentation on Function in C ProgrammingPresentation on Function in C Programming
Presentation on Function in C Programming
Shuvongkor Barman
 
Lecture 1_Functions in C.pptx
Lecture 1_Functions in C.pptxLecture 1_Functions in C.pptx
Lecture 1_Functions in C.pptx
KhurramKhan173
 
Functionincprogram
FunctionincprogramFunctionincprogram
Functionincprogram
Sampath Kumar
 
unit_2 (1).pptx
unit_2 (1).pptxunit_2 (1).pptx
unit_2 (1).pptx
JVenkateshGoud
 
Function in c
Function in cFunction in c
Function in c
savitamhaske
 
C function
C functionC function
C function
thirumalaikumar3
 
1. DSA - Introduction.pptx
1. DSA - Introduction.pptx1. DSA - Introduction.pptx
1. DSA - Introduction.pptx
hara69
 
CH.4FUNCTIONS IN C_FYBSC(CS).pptx
CH.4FUNCTIONS IN C_FYBSC(CS).pptxCH.4FUNCTIONS IN C_FYBSC(CS).pptx
CH.4FUNCTIONS IN C_FYBSC(CS).pptx
SangeetaBorde3
 
46630497 fun-pointer-1
46630497 fun-pointer-146630497 fun-pointer-1
46630497 fun-pointer-1
AmIt Prasad
 
unit_2.pptx
unit_2.pptxunit_2.pptx
unit_2.pptx
Venkatesh Goud
 
presentation_functions_1443207686_140676.ppt
presentation_functions_1443207686_140676.pptpresentation_functions_1443207686_140676.ppt
presentation_functions_1443207686_140676.ppt
SandipPradhan23
 
Unit_5Functionspptx__2022_12_27_10_47_17 (1).pptx
Unit_5Functionspptx__2022_12_27_10_47_17 (1).pptxUnit_5Functionspptx__2022_12_27_10_47_17 (1).pptx
Unit_5Functionspptx__2022_12_27_10_47_17 (1).pptx
vekariyakashyap
 
Function in c program
Function in c programFunction in c program
Function in c program
umesh patil
 
VIT351 Software Development VI Unit1
VIT351 Software Development VI Unit1VIT351 Software Development VI Unit1
VIT351 Software Development VI Unit1
YOGESH SINGH
 
4th unit full
4th unit full4th unit full
4th unit full
Murali Saktheeswaran
 
C structure
C structureC structure
C structure
ankush9927
 
Functions IN CPROGRAMMING OF ENGINEERING.pptx
Functions IN CPROGRAMMING OF ENGINEERING.pptxFunctions IN CPROGRAMMING OF ENGINEERING.pptx
Functions IN CPROGRAMMING OF ENGINEERING.pptx
vanshhans21102005
 
Fundamentals of functions in C program.pptx
Fundamentals of functions in C program.pptxFundamentals of functions in C program.pptx
Fundamentals of functions in C program.pptx
Chandrakant Divate
 

Similar to Pointers and call by value, reference, address in C (20)

Preprocessor directives
Preprocessor directivesPreprocessor directives
Preprocessor directives
 
Unit 3 (1)
Unit 3 (1)Unit 3 (1)
Unit 3 (1)
 
Presentation on Function in C Programming
Presentation on Function in C ProgrammingPresentation on Function in C Programming
Presentation on Function in C Programming
 
Lecture 1_Functions in C.pptx
Lecture 1_Functions in C.pptxLecture 1_Functions in C.pptx
Lecture 1_Functions in C.pptx
 
Functionincprogram
FunctionincprogramFunctionincprogram
Functionincprogram
 
unit_2 (1).pptx
unit_2 (1).pptxunit_2 (1).pptx
unit_2 (1).pptx
 
Function in c
Function in cFunction in c
Function in c
 
C function
C functionC function
C function
 
1. DSA - Introduction.pptx
1. DSA - Introduction.pptx1. DSA - Introduction.pptx
1. DSA - Introduction.pptx
 
CH.4FUNCTIONS IN C_FYBSC(CS).pptx
CH.4FUNCTIONS IN C_FYBSC(CS).pptxCH.4FUNCTIONS IN C_FYBSC(CS).pptx
CH.4FUNCTIONS IN C_FYBSC(CS).pptx
 
46630497 fun-pointer-1
46630497 fun-pointer-146630497 fun-pointer-1
46630497 fun-pointer-1
 
unit_2.pptx
unit_2.pptxunit_2.pptx
unit_2.pptx
 
presentation_functions_1443207686_140676.ppt
presentation_functions_1443207686_140676.pptpresentation_functions_1443207686_140676.ppt
presentation_functions_1443207686_140676.ppt
 
Unit_5Functionspptx__2022_12_27_10_47_17 (1).pptx
Unit_5Functionspptx__2022_12_27_10_47_17 (1).pptxUnit_5Functionspptx__2022_12_27_10_47_17 (1).pptx
Unit_5Functionspptx__2022_12_27_10_47_17 (1).pptx
 
Function in c program
Function in c programFunction in c program
Function in c program
 
VIT351 Software Development VI Unit1
VIT351 Software Development VI Unit1VIT351 Software Development VI Unit1
VIT351 Software Development VI Unit1
 
4th unit full
4th unit full4th unit full
4th unit full
 
C structure
C structureC structure
C structure
 
Functions IN CPROGRAMMING OF ENGINEERING.pptx
Functions IN CPROGRAMMING OF ENGINEERING.pptxFunctions IN CPROGRAMMING OF ENGINEERING.pptx
Functions IN CPROGRAMMING OF ENGINEERING.pptx
 
Fundamentals of functions in C program.pptx
Fundamentals of functions in C program.pptxFundamentals of functions in C program.pptx
Fundamentals of functions in C program.pptx
 

More from Syed Mustafa

BPOPS203 PRINCIPLES OF PROGRAMMING USING C LAB Manual.pdf
BPOPS203 PRINCIPLES OF PROGRAMMING USING C LAB Manual.pdfBPOPS203 PRINCIPLES OF PROGRAMMING USING C LAB Manual.pdf
BPOPS203 PRINCIPLES OF PROGRAMMING USING C LAB Manual.pdf
Syed Mustafa
 
18CSL58 DBMS LAB Manual.pdf
18CSL58 DBMS LAB Manual.pdf18CSL58 DBMS LAB Manual.pdf
18CSL58 DBMS LAB Manual.pdf
Syed Mustafa
 
Syed IoT - module 5
Syed  IoT - module 5Syed  IoT - module 5
Syed IoT - module 5
Syed Mustafa
 
IoT - module 4
IoT - module 4IoT - module 4
IoT - module 4
Syed Mustafa
 
15CS81- IoT- VTU- module 3
15CS81- IoT- VTU- module 315CS81- IoT- VTU- module 3
15CS81- IoT- VTU- module 3
Syed Mustafa
 
15CS81- IoT Module-2
15CS81- IoT Module-215CS81- IoT Module-2
15CS81- IoT Module-2
Syed Mustafa
 
Internet of Things - module 1
Internet of Things -  module 1Internet of Things -  module 1
Internet of Things - module 1
Syed Mustafa
 
15CS664- Python Application Programming- Question bank 1
15CS664- Python Application Programming- Question bank 115CS664- Python Application Programming- Question bank 1
15CS664- Python Application Programming- Question bank 1
Syed Mustafa
 
15CS664- Python Application Programming VTU syllabus
15CS664- Python Application Programming  VTU syllabus15CS664- Python Application Programming  VTU syllabus
15CS664- Python Application Programming VTU syllabus
Syed Mustafa
 
15CS664- Python Application Programming - Module 3
15CS664- Python Application Programming - Module 315CS664- Python Application Programming - Module 3
15CS664- Python Application Programming - Module 3
Syed Mustafa
 
15CS664-Python Application Programming - Module 3 and 4
15CS664-Python Application Programming - Module 3 and 415CS664-Python Application Programming - Module 3 and 4
15CS664-Python Application Programming - Module 3 and 4
Syed Mustafa
 
15CS664 Python Question Bank-3
15CS664 Python Question Bank-315CS664 Python Question Bank-3
15CS664 Python Question Bank-3
Syed Mustafa
 
Data structures lab manual
Data structures lab manualData structures lab manual
Data structures lab manual
Syed Mustafa
 
Usp notes unit6-8
Usp notes unit6-8Usp notes unit6-8
Usp notes unit6-8
Syed Mustafa
 
Grid computing notes
Grid computing notesGrid computing notes
Grid computing notes
Syed Mustafa
 
Unix system programming
Unix system programmingUnix system programming
Unix system programming
Syed Mustafa
 
answer-model-qp-15-pcd13pcd
answer-model-qp-15-pcd13pcdanswer-model-qp-15-pcd13pcd
answer-model-qp-15-pcd13pcd
Syed Mustafa
 
VTU PCD Model Question Paper - Programming in C
VTU PCD Model Question Paper - Programming in CVTU PCD Model Question Paper - Programming in C
VTU PCD Model Question Paper - Programming in C
Syed Mustafa
 
Data structures lab c programs
Data structures lab  c programsData structures lab  c programs
Data structures lab c programs
Syed Mustafa
 
Infix prefix postfix expression -conversion
Infix  prefix postfix expression -conversionInfix  prefix postfix expression -conversion
Infix prefix postfix expression -conversion
Syed Mustafa
 

More from Syed Mustafa (20)

BPOPS203 PRINCIPLES OF PROGRAMMING USING C LAB Manual.pdf
BPOPS203 PRINCIPLES OF PROGRAMMING USING C LAB Manual.pdfBPOPS203 PRINCIPLES OF PROGRAMMING USING C LAB Manual.pdf
BPOPS203 PRINCIPLES OF PROGRAMMING USING C LAB Manual.pdf
 
18CSL58 DBMS LAB Manual.pdf
18CSL58 DBMS LAB Manual.pdf18CSL58 DBMS LAB Manual.pdf
18CSL58 DBMS LAB Manual.pdf
 
Syed IoT - module 5
Syed  IoT - module 5Syed  IoT - module 5
Syed IoT - module 5
 
IoT - module 4
IoT - module 4IoT - module 4
IoT - module 4
 
15CS81- IoT- VTU- module 3
15CS81- IoT- VTU- module 315CS81- IoT- VTU- module 3
15CS81- IoT- VTU- module 3
 
15CS81- IoT Module-2
15CS81- IoT Module-215CS81- IoT Module-2
15CS81- IoT Module-2
 
Internet of Things - module 1
Internet of Things -  module 1Internet of Things -  module 1
Internet of Things - module 1
 
15CS664- Python Application Programming- Question bank 1
15CS664- Python Application Programming- Question bank 115CS664- Python Application Programming- Question bank 1
15CS664- Python Application Programming- Question bank 1
 
15CS664- Python Application Programming VTU syllabus
15CS664- Python Application Programming  VTU syllabus15CS664- Python Application Programming  VTU syllabus
15CS664- Python Application Programming VTU syllabus
 
15CS664- Python Application Programming - Module 3
15CS664- Python Application Programming - Module 315CS664- Python Application Programming - Module 3
15CS664- Python Application Programming - Module 3
 
15CS664-Python Application Programming - Module 3 and 4
15CS664-Python Application Programming - Module 3 and 415CS664-Python Application Programming - Module 3 and 4
15CS664-Python Application Programming - Module 3 and 4
 
15CS664 Python Question Bank-3
15CS664 Python Question Bank-315CS664 Python Question Bank-3
15CS664 Python Question Bank-3
 
Data structures lab manual
Data structures lab manualData structures lab manual
Data structures lab manual
 
Usp notes unit6-8
Usp notes unit6-8Usp notes unit6-8
Usp notes unit6-8
 
Grid computing notes
Grid computing notesGrid computing notes
Grid computing notes
 
Unix system programming
Unix system programmingUnix system programming
Unix system programming
 
answer-model-qp-15-pcd13pcd
answer-model-qp-15-pcd13pcdanswer-model-qp-15-pcd13pcd
answer-model-qp-15-pcd13pcd
 
VTU PCD Model Question Paper - Programming in C
VTU PCD Model Question Paper - Programming in CVTU PCD Model Question Paper - Programming in C
VTU PCD Model Question Paper - Programming in C
 
Data structures lab c programs
Data structures lab  c programsData structures lab  c programs
Data structures lab c programs
 
Infix prefix postfix expression -conversion
Infix  prefix postfix expression -conversionInfix  prefix postfix expression -conversion
Infix prefix postfix expression -conversion
 

Recently uploaded

Heap Sort (SS).ppt FOR ENGINEERING GRADUATES, BCA, MCA, MTECH, BSC STUDENTS
Heap Sort (SS).ppt FOR ENGINEERING GRADUATES, BCA, MCA, MTECH, BSC STUDENTSHeap Sort (SS).ppt FOR ENGINEERING GRADUATES, BCA, MCA, MTECH, BSC STUDENTS
Heap Sort (SS).ppt FOR ENGINEERING GRADUATES, BCA, MCA, MTECH, BSC STUDENTS
Soumen Santra
 
Fundamentals of Electric Drives and its applications.pptx
Fundamentals of Electric Drives and its applications.pptxFundamentals of Electric Drives and its applications.pptx
Fundamentals of Electric Drives and its applications.pptx
manasideore6
 
Understanding Inductive Bias in Machine Learning
Understanding Inductive Bias in Machine LearningUnderstanding Inductive Bias in Machine Learning
Understanding Inductive Bias in Machine Learning
SUTEJAS
 
Design and Analysis of Algorithms-DP,Backtracking,Graphs,B&B
Design and Analysis of Algorithms-DP,Backtracking,Graphs,B&BDesign and Analysis of Algorithms-DP,Backtracking,Graphs,B&B
Design and Analysis of Algorithms-DP,Backtracking,Graphs,B&B
Sreedhar Chowdam
 
Nuclear Power Economics and Structuring 2024
Nuclear Power Economics and Structuring 2024Nuclear Power Economics and Structuring 2024
Nuclear Power Economics and Structuring 2024
Massimo Talia
 
AKS UNIVERSITY Satna Final Year Project By OM Hardaha.pdf
AKS UNIVERSITY Satna Final Year Project By OM Hardaha.pdfAKS UNIVERSITY Satna Final Year Project By OM Hardaha.pdf
AKS UNIVERSITY Satna Final Year Project By OM Hardaha.pdf
SamSarthak3
 
Student information management system project report ii.pdf
Student information management system project report ii.pdfStudent information management system project report ii.pdf
Student information management system project report ii.pdf
Kamal Acharya
 
Online aptitude test management system project report.pdf
Online aptitude test management system project report.pdfOnline aptitude test management system project report.pdf
Online aptitude test management system project report.pdf
Kamal Acharya
 
Hierarchical Digital Twin of a Naval Power System
Hierarchical Digital Twin of a Naval Power SystemHierarchical Digital Twin of a Naval Power System
Hierarchical Digital Twin of a Naval Power System
Kerry Sado
 
在线办理(ANU毕业证书)澳洲国立大学毕业证录取通知书一模一样
在线办理(ANU毕业证书)澳洲国立大学毕业证录取通知书一模一样在线办理(ANU毕业证书)澳洲国立大学毕业证录取通知书一模一样
在线办理(ANU毕业证书)澳洲国立大学毕业证录取通知书一模一样
obonagu
 
Recycled Concrete Aggregate in Construction Part III
Recycled Concrete Aggregate in Construction Part IIIRecycled Concrete Aggregate in Construction Part III
Recycled Concrete Aggregate in Construction Part III
Aditya Rajan Patra
 
MCQ Soil mechanics questions (Soil shear strength).pdf
MCQ Soil mechanics questions (Soil shear strength).pdfMCQ Soil mechanics questions (Soil shear strength).pdf
MCQ Soil mechanics questions (Soil shear strength).pdf
Osamah Alsalih
 
basic-wireline-operations-course-mahmoud-f-radwan.pdf
basic-wireline-operations-course-mahmoud-f-radwan.pdfbasic-wireline-operations-course-mahmoud-f-radwan.pdf
basic-wireline-operations-course-mahmoud-f-radwan.pdf
NidhalKahouli2
 
PPT on GRP pipes manufacturing and testing
PPT on GRP pipes manufacturing and testingPPT on GRP pipes manufacturing and testing
PPT on GRP pipes manufacturing and testing
anoopmanoharan2
 
Hybrid optimization of pumped hydro system and solar- Engr. Abdul-Azeez.pdf
Hybrid optimization of pumped hydro system and solar- Engr. Abdul-Azeez.pdfHybrid optimization of pumped hydro system and solar- Engr. Abdul-Azeez.pdf
Hybrid optimization of pumped hydro system and solar- Engr. Abdul-Azeez.pdf
fxintegritypublishin
 
An Approach to Detecting Writing Styles Based on Clustering Techniques
An Approach to Detecting Writing Styles Based on Clustering TechniquesAn Approach to Detecting Writing Styles Based on Clustering Techniques
An Approach to Detecting Writing Styles Based on Clustering Techniques
ambekarshweta25
 
Harnessing WebAssembly for Real-time Stateless Streaming Pipelines
Harnessing WebAssembly for Real-time Stateless Streaming PipelinesHarnessing WebAssembly for Real-time Stateless Streaming Pipelines
Harnessing WebAssembly for Real-time Stateless Streaming Pipelines
Christina Lin
 
Sachpazis:Terzaghi Bearing Capacity Estimation in simple terms with Calculati...
Sachpazis:Terzaghi Bearing Capacity Estimation in simple terms with Calculati...Sachpazis:Terzaghi Bearing Capacity Estimation in simple terms with Calculati...
Sachpazis:Terzaghi Bearing Capacity Estimation in simple terms with Calculati...
Dr.Costas Sachpazis
 
RAT: Retrieval Augmented Thoughts Elicit Context-Aware Reasoning in Long-Hori...
RAT: Retrieval Augmented Thoughts Elicit Context-Aware Reasoning in Long-Hori...RAT: Retrieval Augmented Thoughts Elicit Context-Aware Reasoning in Long-Hori...
RAT: Retrieval Augmented Thoughts Elicit Context-Aware Reasoning in Long-Hori...
thanhdowork
 
14 Template Contractual Notice - EOT Application
14 Template Contractual Notice - EOT Application14 Template Contractual Notice - EOT Application
14 Template Contractual Notice - EOT Application
SyedAbiiAzazi1
 

Recently uploaded (20)

Heap Sort (SS).ppt FOR ENGINEERING GRADUATES, BCA, MCA, MTECH, BSC STUDENTS
Heap Sort (SS).ppt FOR ENGINEERING GRADUATES, BCA, MCA, MTECH, BSC STUDENTSHeap Sort (SS).ppt FOR ENGINEERING GRADUATES, BCA, MCA, MTECH, BSC STUDENTS
Heap Sort (SS).ppt FOR ENGINEERING GRADUATES, BCA, MCA, MTECH, BSC STUDENTS
 
Fundamentals of Electric Drives and its applications.pptx
Fundamentals of Electric Drives and its applications.pptxFundamentals of Electric Drives and its applications.pptx
Fundamentals of Electric Drives and its applications.pptx
 
Understanding Inductive Bias in Machine Learning
Understanding Inductive Bias in Machine LearningUnderstanding Inductive Bias in Machine Learning
Understanding Inductive Bias in Machine Learning
 
Design and Analysis of Algorithms-DP,Backtracking,Graphs,B&B
Design and Analysis of Algorithms-DP,Backtracking,Graphs,B&BDesign and Analysis of Algorithms-DP,Backtracking,Graphs,B&B
Design and Analysis of Algorithms-DP,Backtracking,Graphs,B&B
 
Nuclear Power Economics and Structuring 2024
Nuclear Power Economics and Structuring 2024Nuclear Power Economics and Structuring 2024
Nuclear Power Economics and Structuring 2024
 
AKS UNIVERSITY Satna Final Year Project By OM Hardaha.pdf
AKS UNIVERSITY Satna Final Year Project By OM Hardaha.pdfAKS UNIVERSITY Satna Final Year Project By OM Hardaha.pdf
AKS UNIVERSITY Satna Final Year Project By OM Hardaha.pdf
 
Student information management system project report ii.pdf
Student information management system project report ii.pdfStudent information management system project report ii.pdf
Student information management system project report ii.pdf
 
Online aptitude test management system project report.pdf
Online aptitude test management system project report.pdfOnline aptitude test management system project report.pdf
Online aptitude test management system project report.pdf
 
Hierarchical Digital Twin of a Naval Power System
Hierarchical Digital Twin of a Naval Power SystemHierarchical Digital Twin of a Naval Power System
Hierarchical Digital Twin of a Naval Power System
 
在线办理(ANU毕业证书)澳洲国立大学毕业证录取通知书一模一样
在线办理(ANU毕业证书)澳洲国立大学毕业证录取通知书一模一样在线办理(ANU毕业证书)澳洲国立大学毕业证录取通知书一模一样
在线办理(ANU毕业证书)澳洲国立大学毕业证录取通知书一模一样
 
Recycled Concrete Aggregate in Construction Part III
Recycled Concrete Aggregate in Construction Part IIIRecycled Concrete Aggregate in Construction Part III
Recycled Concrete Aggregate in Construction Part III
 
MCQ Soil mechanics questions (Soil shear strength).pdf
MCQ Soil mechanics questions (Soil shear strength).pdfMCQ Soil mechanics questions (Soil shear strength).pdf
MCQ Soil mechanics questions (Soil shear strength).pdf
 
basic-wireline-operations-course-mahmoud-f-radwan.pdf
basic-wireline-operations-course-mahmoud-f-radwan.pdfbasic-wireline-operations-course-mahmoud-f-radwan.pdf
basic-wireline-operations-course-mahmoud-f-radwan.pdf
 
PPT on GRP pipes manufacturing and testing
PPT on GRP pipes manufacturing and testingPPT on GRP pipes manufacturing and testing
PPT on GRP pipes manufacturing and testing
 
Hybrid optimization of pumped hydro system and solar- Engr. Abdul-Azeez.pdf
Hybrid optimization of pumped hydro system and solar- Engr. Abdul-Azeez.pdfHybrid optimization of pumped hydro system and solar- Engr. Abdul-Azeez.pdf
Hybrid optimization of pumped hydro system and solar- Engr. Abdul-Azeez.pdf
 
An Approach to Detecting Writing Styles Based on Clustering Techniques
An Approach to Detecting Writing Styles Based on Clustering TechniquesAn Approach to Detecting Writing Styles Based on Clustering Techniques
An Approach to Detecting Writing Styles Based on Clustering Techniques
 
Harnessing WebAssembly for Real-time Stateless Streaming Pipelines
Harnessing WebAssembly for Real-time Stateless Streaming PipelinesHarnessing WebAssembly for Real-time Stateless Streaming Pipelines
Harnessing WebAssembly for Real-time Stateless Streaming Pipelines
 
Sachpazis:Terzaghi Bearing Capacity Estimation in simple terms with Calculati...
Sachpazis:Terzaghi Bearing Capacity Estimation in simple terms with Calculati...Sachpazis:Terzaghi Bearing Capacity Estimation in simple terms with Calculati...
Sachpazis:Terzaghi Bearing Capacity Estimation in simple terms with Calculati...
 
RAT: Retrieval Augmented Thoughts Elicit Context-Aware Reasoning in Long-Hori...
RAT: Retrieval Augmented Thoughts Elicit Context-Aware Reasoning in Long-Hori...RAT: Retrieval Augmented Thoughts Elicit Context-Aware Reasoning in Long-Hori...
RAT: Retrieval Augmented Thoughts Elicit Context-Aware Reasoning in Long-Hori...
 
14 Template Contractual Notice - EOT Application
14 Template Contractual Notice - EOT Application14 Template Contractual Notice - EOT Application
14 Template Contractual Notice - EOT Application
 

Pointers and call by value, reference, address in C

  • 1. Programming in C –Call By Prof. A. Syed Mustafa, HKBK College of Engineering Program to find area of a circle using #define. #include<stdio.h> #define PI 3.1412 int main() { int radius; float area; printf("Enter the radius: "); scanf("%d", &radius); area=PI*radius*radius; printf("Area=%.2f",area); return 0; } Use of #if, #elif, #else and #endif : The preprocessor directives #if, #elif, #else and #endif allows to conditionally compile a block of code based on predefined symbols. #include<stdio.h> #define MAX 100 void main( ) { #if (MAX) printf("MAX is defined"); #else printf ("MAX is not defined"); #endif } Preprocessor Directive / Macros The C preprocessor [CPP] is a macro processor that is used automatically by the C compiler to transform programmer defined programs before actual compilation takes place. It is called a macro processor because it allows the user to define macros, which are short abbreviations for longer constructs. It instructs the compiler to do required pre-processing before the actual compilation. All preprocessor directives begin with the # symbol (known as pound or hash). List of pre-processor directives: 1. #include: This is used insert a particular header from another file. 2. #define, #undef : These are used to define and un-define conditional compilation symbols. 3. #if, #elif, #else, #endif : These are used to conditionally skip sections of source code. Example: #include “demo.h”  tells CPP to get demo.h from the local directory and add the content to the current source file. #define PI 3.1412 /* defines symbolic constant */  This directive tells the CPP to replace symbolic constant pi with 3.1412. #define SIZE 5 /* SIZE will be replaced with 5 */
  • 2. Programming in C –Call By Prof. A. Syed Mustafa, HKBK College of Engineering MEMORY ALLOCATION FUNCTIONS 1. Static Memory Allocation: Memory space allocated from stack at compile time for variables declared in the program is fixed, it cannot be altered during execution-time. This is called static memory allocation. Example: int a[5]; float d; 2. Dynamic Memory Allocation It is the process of allocating memory-space during execution-time i.e. run time from Heap. If there is an unpredictable storage requirement, then the dynamic allocation technique is used. This allocation technique uses predefined functions to allocate and release memory for data during execution-time. There are 4 library functions for dynamic memory allocation: malloc( ), calloc( ), free( ), realloc( ) These library functions are defined under "stdlib.h" 1. malloc( ) -memory allocation This function is used to allocate the required memory-space during execution-time. The syntax is shown below: data_type *p; p=(data_type*)malloc(size); Here p is pointer variable. data_type can be int, float or char. size is number of bytes to be allocated.If memory is successfully allocated, then address of the first byte of allocated space is returned. If memory allocation fails, then NULL is returned. For ex: int *ptr; ptr=(int*)malloc(100*sizeof(int)); The above code will allocate 200 bytes assuming sizeof(int)=2 bytes. 2. calloc( ) - contiguous allocation This function is used to allocate the required memory-size during execution-time and at the same time, automatically initialize memory with 0's. syntax : data_type *p; p=(data_type*)calloc(n,size); Ex: p=(int*)calloc(25,sizeof(int)); 3. free( ) Dynamically allocated memory with either calloc( ) or malloc( ) can be deallocated using free( ) explicitly to release space. syntax: free(ptr); 4. realloc() -reallocation If the previously allocated memory is insufficient or more than sufficient. Then, we can change memory-size previously allocated using realloc(). The syntax is shown below: ptr=(data_type*)realloc(ptr,newsize); void main( ) { int i; int *a= (int *)malloc(10); for(i=0;i<5;i++) *(a+i)=i+10; for(i=0;i<5;i++) printf(“%dt”,*(a+i)10; } Output: 10 11 12 13 14
  • 3. Programming in C –Call By Prof. A. Syed Mustafa, HKBK College of Engineering Pointers A Pointer is just an address of the data stored in memory. A pointer is a variable whose value is the address of another variable, i.e., direct address of the memory location. Syntax: <variable_type> *<name>=&variable; eg:- int *a=&b; ‘*’ used to declare a pointer variable and also used to retrieve the value from the pointed memory location. ‘*’ is also called as derefence operator. #include <stdio.h> void main () { int a = 20; /* actual variable declaration */ int *ip; /* pointer variable declaration */ ip = &a; /* store address of var in pointer variable*/ printf("Address of variable a is: %xn", &a ); /* address stored in pointer variable */ printf("Address stored in variable ip is: %xn", ip ); /* access the value using the pointer */ printf("Value of *ip variable: %dn", *ip ); } Output: Address of variable a is: bffd8b3c Address stored in variable ip is: bffd8b3c Value of *ip variable: 20 Actual Parameter  The parameter’s value (or arguments) we provide while calling a function is known as actual arguments.  Parameter Written In Function Call is Called “Actual Parameter”  Actual parameters are parameters as they appear in function calls.  The actual value that is passed into the function by a caller. Formal Parameter  Formal parameters are parameters as they appear in function declarations.  the identifier used in a method to stand for the value that is passed into the function by a caller.  Parameter Written In Function Definition is Called “Formal Parameter”  While declaring a function, the arguments list of parameters we specify are known as formal parameters. Example
  • 4. Programming in C –Call By Prof. A. Syed Mustafa, HKBK College of Engineering CALL BY ADDRESS The call to the function passes variable’s address to the called function. The actual arguments are not copied to the formal arguments, the addresses of actual arguments (or parameters) are passed to the formal parameters. Hence any operation performed by function on formal arguments / parameters affects actual parameters. void swap(int *x, int *y) { int t=*x; *x=*y; *y=t; } void main( ) { int a=5, b=10 ; printf("Before swap: a=%d,b=%d",a,b); swap(&a,&b); /*calling swap function*/ printf("After swap: a= %d,b=%d",a,b); } Output: Before swap: a=5,b=10 After swap: a=10,b=5 Because variable declared ‘a’, ‘b’ in main() is different from variable ‘x’, ’y’ in swap(). Only variable names are different but both a and x, b and y point to the same memory address locations respectively. CALL BY REFERENCE The call to the function passes base address to the called function. The actual arguments are not copied to the formal arguments, only referencing is made. Hence any operation performed by function on formal arguments / parameters affects actual parameters. void change(int b[ ]) { b[0]=10; b[1]=20; b[2]=30; } void main( ) { int a[3]={ 5, 15, 25 } ; printf("BeforeChange:%d,%d,%d",a[0],a[1],a[2]); change(a); /*calling swap function*/ printf("AfterChange:%d,%d,%d",a[0],a[1],a[2]); } Output: BeforeChange: 5,15,25 AfterChange: 10,20,30 Because array variable declared ‘b’ in change() is referencing/ pointing to array variable ‘a’ in main(). Only variable name is different but both are pointing / referencing to same memory address locations. CALL BY VALUE The call to the function passes either the values or the normal variables to the called function. The actual arguments are copied to the formal arguments, hence any operation performed by function on arguments doesn’t affect actual parameters. void swap(int a, int b) { int t=a; a=b; b=t; } void main( ) { int a=5, b=10 ; printf("Before swap: a=%d,b=%d",a,b); swap(a,b); /*calling swap function*/ printf("After swap: a= %d,b=%d",a,b); } Output: Before swap: a=5,b=10 After swap: a=5,b=10 Because variable declared ‘a’, ‘b’ in main() is different from variable ‘a’, ’b’ in swap(). Only variable names are similar but their memory address are different and stored in different memory locations.
  • 5. Programming in C –Call By Prof. A. Syed Mustafa, HKBK College of Engineering STACKS • A stack is a special type of data structure where elements are inserted from one end and elements are deleted from the same end. • Using this approach, the Last element Inserted is the First element to be deleted Out, and hence, stack is also called LIFO data structure. • The various operations performed on stack: Insert: An element is inserted from top end. Insertion operation is called push operation. Delete: An element is deleted from top end. Deletion operation is called pop operation. Overflow: Check whether the stack is full or not. Underflow: Check whether the stack is empty or not. • This can be pictorially represented as shown below: APPLICATIONS OF STACK 1) Conversion of expressions: The compiler converts the infix expressions into postfix expressions using stack. 2) Evaluation of expression: An arithmetic expression represented in the form of either postfix or prefix can be easily evaluated using stack. 3) Recursion: A function which calls itself is called recursive function. 4) Other applications: To find whether the string is a palindrome, to check whether a given expression is valid or not.
  • 6. Programming in C –Call By Prof. A. Syed Mustafa, HKBK College of Engineering PRIMITIVE AND NON-PRIMITIVE DATA TYPES Data type specifies the type of data stored in a variable. The data type can be classified into two types: 1) Primitive data type and 2)Non-Primitive data type Primitive Data Type • The primitive data types are the basic data types that are available in most of the programming languages. • The primitive data types are used to represent single values. Integer: This is used to represent a number without decimal point. Eg: int a=12; Float: This is used to represent a number with decimal point. Eg: float a=45.1; double b=67.3; Character: This is used to represent single character Eg: char ch=‘C’; char ch1= ‘a’; Non Primitive Data Type • The data types that are derived from primary data types are known as non-Primitive data types. • These datatypes are used to store group of values. • The non-primitive data types are Arrays, Structure Stacks, Linked list Queue, Binary tree