Building Real-Time Data Pipelines: Stream & Batch Processing workshop Slide
Functions with heap and stack....by thanveer danish
1.
2. Disclaimer: This presentation is prepared by trainees of
baabtra as a part of mentoring program. This is not official
document of baabtra –Mentoring Partner
Baabtra-Mentoring Partner is the mentoring division of baabte System Technologies Pvt .
Ltd
3. Functions with heap and stack
MUHAMMED THANVEER.M
kutubmadar@gmail.com
www.facebook.com/username
twitter.com/username
in.linkedin.com/in/profilename
9526960445
4. There are two ways momery can allocated in c
By declaring variables (stack)
By explicitly requesting space from c(heap)
5. Stack
It is the place where all the variables that are declared and
initialized before run time are stored
The advantage of using the stack to store variables, is that memory is
managed for you. You don't have to allocate memory by hand, or free it
once you don't need it any more. What's more, because the CPU
organizes stack memory so efficiently, reading from and writing to
stack variables is very fast.
oIt is follows last in first out order
6. Example
Main()
{
Int a=10, b=20, c;
C=sum( a,b);
}
Int sum(int a,int b)
{
Int c;
C=a+b;
Return c;
}
7. Heap
Heap is a area of memory used for dynamically memory
allocation
Programmer allocates memory mannually at heap
To allocate memory using by calloc ,malloc and realloc functions
Malloc and calloc ‘s purpose same…but realloc allocation to adjust it
after allocating memory..
9. Recursive function
Recursion is the process of repeating items in a
self-similar way. Same applies in programming
languages as well where if a programming allows
you to call a function inside the same function that
is called recursive call of the function
Example
void main()
{
printf(“recursive function called.n”);
main();
}
10. A recursive function is a function which calls itself.
The speed of a recursive program is slower because of
stack overheads. (This attribute is evident if you run above
C program.)
A recursive function must have recursive conditions,
terminating conditions, and recursive expressions.
11. If this presentation helped you, please visit our
page facebook.com/baabtra and like it.
Thanks in advance.
www.baabtra.com | www.massbaab.com |www.baabte.com
12. Contact Us
Emarald Mall (Big Bazar Building)
Mavoor Road, Kozhikode,
Kerala, India.
Ph: + 91 – 495 40 25 550
NC Complex, Near Bus Stand
Mukkam, Kozhikode,
Kerala, India.
Ph: + 91 – 495 40 25 550
Start up Village
Eranakulam,
Kerala, India.
Email: info@baabtra.com