SlideShare a Scribd company logo
Functions with heap and stack....by thanveer danish
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
Functions with heap and stack 
MUHAMMED THANVEER.M 
kutubmadar@gmail.com 
www.facebook.com/username 
twitter.com/username 
in.linkedin.com/in/profilename 
9526960445
There are two ways momery can allocated in c 
By declaring variables (stack) 
By explicitly requesting space from c(heap)
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
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; 
}
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..
example 
#include <stdio.h> 
#include <string.h> 
#include <stdlib.h> 
int main() 
{ 
char *mem_allocation; 
/* memory is allocated dynamically */ 
mem_allocation = malloc( 20 * sizeof(char) ); 
if( mem_allocation== NULL ) 
{ 
printf("Couldn't able to allocate requested memoryn"); 
} 
else 
{ 
strcpy( mem_allocation,“shernoobi@gmail.com"); 
} 
printf("Dynamically allocated memory content : " 
"%sn", mem_allocation ); 
free(mem_allocation); 
}
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(); 
}
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.
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
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

More Related Content

What's hot (6)

PPTX
Dynamic Memory Allocation(DMA)
Kamal Acharya
 
PPTX
C dynamic ppt
RJ Mehul Gadhiya
 
PDF
15 Jo P Mar 08
Ganesh Samarthyam
 
PPTX
Programming Environment in Matlab
DataminingTools Inc
 
PPT
Dynamic Memory Allocation
vaani pathak
 
Dynamic Memory Allocation(DMA)
Kamal Acharya
 
C dynamic ppt
RJ Mehul Gadhiya
 
15 Jo P Mar 08
Ganesh Samarthyam
 
Programming Environment in Matlab
DataminingTools Inc
 
Dynamic Memory Allocation
vaani pathak
 

Viewers also liked (6)

PPTX
Test powerpoint presentation
allaynew
 
PPT
Manual testing ppt
Santosh Maranabasari
 
PPT
Testing concepts ppt
Rathna Priya
 
PPT
Software Testing Fundamentals
Chankey Pathak
 
PPT
Software testing basic concepts
Hưng Hoàng
 
PPTX
Software testing ppt
Heritage Institute Of Tech,India
 
Test powerpoint presentation
allaynew
 
Manual testing ppt
Santosh Maranabasari
 
Testing concepts ppt
Rathna Priya
 
Software Testing Fundamentals
Chankey Pathak
 
Software testing basic concepts
Hưng Hoàng
 
Software testing ppt
Heritage Institute Of Tech,India
 
Ad

Similar to Functions with heap and stack....by thanveer danish (20)

PPTX
Functions with heap and stack
baabtra.com - No. 1 supplier of quality freshers
 
PPTX
Functions with heap and stack
baabtra.com - No. 1 supplier of quality freshers
 
PPTX
Functions using stack and heap
baabtra.com - No. 1 supplier of quality freshers
 
PPTX
Lecture 3.3.1 Dynamic Memory Allocation and Functions.pptx
roykaustav382
 
PPTX
Functions with heap and stack
baabtra.com - No. 1 supplier of quality freshers
 
PDF
Function with heap and stack
baabtra.com - No. 1 supplier of quality freshers
 
PPTX
Stack & heap
Shajahan T S Shah
 
PPTX
Programming in C sesion 2
Prerna Sharma
 
PDF
C interview-questions-techpreparation
Kushaal Singla
 
PDF
C interview questions
Soba Arjun
 
PPTX
Dynamic Memory Allocation in C
Vijayananda Ratnam Ch
 
PPT
Database structure Structures Link list and trees and Recurison complete
Adnan abid
 
PDF
C Interview Questions PDF By Scholarhat.pdf
Scholarhat
 
PPT
Data structures &amp;algorithms
Nur Saleha
 
PPT
C++ and Data Structure.ppt
Rich Alex
 
PPTX
Introduction to functions in C programming language
ssuserbad56d
 
Functions using stack and heap
baabtra.com - No. 1 supplier of quality freshers
 
Lecture 3.3.1 Dynamic Memory Allocation and Functions.pptx
roykaustav382
 
Stack & heap
Shajahan T S Shah
 
Programming in C sesion 2
Prerna Sharma
 
C interview-questions-techpreparation
Kushaal Singla
 
C interview questions
Soba Arjun
 
Dynamic Memory Allocation in C
Vijayananda Ratnam Ch
 
Database structure Structures Link list and trees and Recurison complete
Adnan abid
 
C Interview Questions PDF By Scholarhat.pdf
Scholarhat
 
Data structures &amp;algorithms
Nur Saleha
 
C++ and Data Structure.ppt
Rich Alex
 
Introduction to functions in C programming language
ssuserbad56d
 
Ad

More from Muhammed Thanveer M (20)

DOCX
Easy check is simple and easy use lodge management system
Muhammed Thanveer M
 
DOCX
KEYBAN...MODULES
Muhammed Thanveer M
 
PPTX
KeyBan....easy to think and work
Muhammed Thanveer M
 
PPTX
Codeinator
Muhammed Thanveer M
 
DOCX
mysql ....question and answer by muhammed thanveer melayi
Muhammed Thanveer M
 
PPTX
Transation.....thanveeer
Muhammed Thanveer M
 
PPTX
Stored procedures by thanveer danish melayi
Muhammed Thanveer M
 
PPTX
Statements,joins and operators in sql by thanveer danish melayi(1)
Muhammed Thanveer M
 
PPTX
Udf&views in sql...by thanveer melayi
Muhammed Thanveer M
 
PPTX
Aptitude Questions-2
Muhammed Thanveer M
 
DOCX
The basics of c programming
Muhammed Thanveer M
 
PPTX
Preprocesser in c
Muhammed Thanveer M
 
PPTX
Elements of c program....by thanveer danish
Muhammed Thanveer M
 
PPTX
Aptitude model by thanveer danish
Muhammed Thanveer M
 
PPTX
Preprocesser in c++ by thanveer danish
Muhammed Thanveer M
 
PPTX
Data base by thanveer danish
Muhammed Thanveer M
 
PPTX
Oop concept in c++ by MUhammed Thanveer Melayi
Muhammed Thanveer M
 
PPTX
Memory allocation in c
Muhammed Thanveer M
 
DOCX
Understanding c file handling functions with examples
Muhammed Thanveer M
 
Easy check is simple and easy use lodge management system
Muhammed Thanveer M
 
KEYBAN...MODULES
Muhammed Thanveer M
 
KeyBan....easy to think and work
Muhammed Thanveer M
 
mysql ....question and answer by muhammed thanveer melayi
Muhammed Thanveer M
 
Transation.....thanveeer
Muhammed Thanveer M
 
Stored procedures by thanveer danish melayi
Muhammed Thanveer M
 
Statements,joins and operators in sql by thanveer danish melayi(1)
Muhammed Thanveer M
 
Udf&views in sql...by thanveer melayi
Muhammed Thanveer M
 
Aptitude Questions-2
Muhammed Thanveer M
 
The basics of c programming
Muhammed Thanveer M
 
Preprocesser in c
Muhammed Thanveer M
 
Elements of c program....by thanveer danish
Muhammed Thanveer M
 
Aptitude model by thanveer danish
Muhammed Thanveer M
 
Preprocesser in c++ by thanveer danish
Muhammed Thanveer M
 
Data base by thanveer danish
Muhammed Thanveer M
 
Oop concept in c++ by MUhammed Thanveer Melayi
Muhammed Thanveer M
 
Memory allocation in c
Muhammed Thanveer M
 
Understanding c file handling functions with examples
Muhammed Thanveer M
 

Recently uploaded (20)

PDF
4K Video Downloader Plus Pro Crack for MacOS New Download 2025
bashirkhan333g
 
PPTX
ChiSquare Procedure in IBM SPSS Statistics Version 31.pptx
Version 1 Analytics
 
PDF
Open Chain Q2 Steering Committee Meeting - 2025-06-25
Shane Coughlan
 
PDF
Empower Your Tech Vision- Why Businesses Prefer to Hire Remote Developers fro...
logixshapers59
 
PDF
MiniTool Power Data Recovery 8.8 With Crack New Latest 2025
bashirkhan333g
 
PDF
Wondershare PDFelement Pro Crack for MacOS New Version Latest 2025
bashirkhan333g
 
PDF
Build It, Buy It, or Already Got It? Make Smarter Martech Decisions
bbedford2
 
PPTX
Hardware(Central Processing Unit ) CU and ALU
RizwanaKalsoom2
 
PPTX
AEM User Group: India Chapter Kickoff Meeting
jennaf3
 
PDF
SAP Firmaya İade ABAB Kodları - ABAB ile yazılmıl hazır kod örneği
Salih Küçük
 
PDF
Automate Cybersecurity Tasks with Python
VICTOR MAESTRE RAMIREZ
 
PDF
IDM Crack with Internet Download Manager 6.42 Build 43 with Patch Latest 2025
bashirkhan333g
 
PPTX
Finding Your License Details in IBM SPSS Statistics Version 31.pptx
Version 1 Analytics
 
PDF
Download Canva Pro 2025 PC Crack Full Latest Version
bashirkhan333g
 
PDF
Odoo CRM vs Zoho CRM: Honest Comparison 2025
Odiware Technologies Private Limited
 
PPTX
Foundations of Marketo Engage - Powering Campaigns with Marketo Personalization
bbedford2
 
PPTX
Coefficient of Variance in IBM SPSS Statistics Version 31.pptx
Version 1 Analytics
 
PDF
TheFutureIsDynamic-BoxLang witch Luis Majano.pdf
Ortus Solutions, Corp
 
PPTX
Customise Your Correlation Table in IBM SPSS Statistics.pptx
Version 1 Analytics
 
PDF
NEW-Viral>Wondershare Filmora 14.5.18.12900 Crack Free
sherryg1122g
 
4K Video Downloader Plus Pro Crack for MacOS New Download 2025
bashirkhan333g
 
ChiSquare Procedure in IBM SPSS Statistics Version 31.pptx
Version 1 Analytics
 
Open Chain Q2 Steering Committee Meeting - 2025-06-25
Shane Coughlan
 
Empower Your Tech Vision- Why Businesses Prefer to Hire Remote Developers fro...
logixshapers59
 
MiniTool Power Data Recovery 8.8 With Crack New Latest 2025
bashirkhan333g
 
Wondershare PDFelement Pro Crack for MacOS New Version Latest 2025
bashirkhan333g
 
Build It, Buy It, or Already Got It? Make Smarter Martech Decisions
bbedford2
 
Hardware(Central Processing Unit ) CU and ALU
RizwanaKalsoom2
 
AEM User Group: India Chapter Kickoff Meeting
jennaf3
 
SAP Firmaya İade ABAB Kodları - ABAB ile yazılmıl hazır kod örneği
Salih Küçük
 
Automate Cybersecurity Tasks with Python
VICTOR MAESTRE RAMIREZ
 
IDM Crack with Internet Download Manager 6.42 Build 43 with Patch Latest 2025
bashirkhan333g
 
Finding Your License Details in IBM SPSS Statistics Version 31.pptx
Version 1 Analytics
 
Download Canva Pro 2025 PC Crack Full Latest Version
bashirkhan333g
 
Odoo CRM vs Zoho CRM: Honest Comparison 2025
Odiware Technologies Private Limited
 
Foundations of Marketo Engage - Powering Campaigns with Marketo Personalization
bbedford2
 
Coefficient of Variance in IBM SPSS Statistics Version 31.pptx
Version 1 Analytics
 
TheFutureIsDynamic-BoxLang witch Luis Majano.pdf
Ortus Solutions, Corp
 
Customise Your Correlation Table in IBM SPSS Statistics.pptx
Version 1 Analytics
 
NEW-Viral>Wondershare Filmora 14.5.18.12900 Crack Free
sherryg1122g
 

Functions with heap and stack....by thanveer danish

  • 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 [email protected] 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..
  • 8. example #include <stdio.h> #include <string.h> #include <stdlib.h> int main() { char *mem_allocation; /* memory is allocated dynamically */ mem_allocation = malloc( 20 * sizeof(char) ); if( mem_allocation== NULL ) { printf("Couldn't able to allocate requested memoryn"); } else { strcpy( mem_allocation,“[email protected]"); } printf("Dynamically allocated memory content : " "%sn", mem_allocation ); free(mem_allocation); }
  • 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: [email protected]