SlideShare a Scribd company logo
Function with heap and stack
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
Week Target Achieved
1 30 23
2
3
Typing Speed
Jobs Applied
Week Company Designation Applied Date Current Status
1
2
3
Functions With Heap and Stack
Muhammed Ajmal IK
ajuik2008@gmail.com
www.facebook.com/username
twitter.com/username
in.linkedin.com/in/profilename
9745020951
Overview
• Introduction
• Stack
• Heap
• Simple program
Introduction
• The memory a program uses is typically divided into
four different areas:
– The code area.
– The heap.
– The stack
Stack
• It is a particular portion of memory.
• It stores temporary variables created by each
function
• variables are allocated and freed automatically
• the stack has size limits
• stack is a last-in, first-out (LIFO) structure
Stack contd..
Stack operation
• Push
• Pop
Heap
• Heap is the area of memory used for dynamic
memory allocation
• Stored in computer RAM just like the stack.
• Function for memory allocation
– Malloc()
– Calloc()
– Realloc()
Heap contd.
• Variables on the heap must be destroyed manually.
• Function for memory deallocation
– Free()
Example for stack
Example for Heap
Find Average of n Number
#include<stdio.h>
#include<stdlib.h>
int main()
{
int *ptr,n,i;
float sum=0.0;
printf("Enter how many Element you want to insert");
scanf("%d",&n);
ptr=malloc(n*sizeof(int));
if(ptr==NULL)
{
printf("Memory not allocated");
exit(0);
}
printf("enter element:");
for(i=0;i<n;++i)
{
scanf("%d",ptr+i);
sum=sum+ *(ptr+i);
}
printf("n Average %f",(sum/n));
free(ptr);
}
Thank you
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
IKK Road,
East Hill, Kozhikode
Kerala, India.
Ph: + 91 – 495 30 63 624
NIT-TBI,
NIT Campus, Kozhikode,
Kerala, India.

More Related Content

Similar to Function with heap and stack (20)

PPTX
Modular enablement
Ori Pomerantz
 
PPT
Java applets
Khan Mac-arther
 
PDF
Software AG Application Modularity - OSGi and JPMS (Jigsaw)
mfrancis
 
PPTX
Memory management, Types of memory, Making the most of your RAM.
Megha Sharma
 
PDF
TechGIG_Memory leaks in_java_webnair_26th_july_2012
Ashish Bhasin
 
PPTX
ERP by saeed
Mohd Saeed
 
PPTX
object oriented programming examples
Abdii Rashid
 
PPTX
Spring AOP
Radhakrishna Mutthoju
 
PDF
Spring batch overivew
Chanyeong Choi
 
PPTX
Storage management
Atul Sharma
 
PDF
Software Engineering : OOAD using UML
Ajit Nayak
 
PDF
0. About this course
IBM Rational software
 
PDF
C- language Lecture 4
Hatem Abd El-Salam
 
PDF
01 Programming for Problem Solving.pdf
A2Zgameggc
 
Modular enablement
Ori Pomerantz
 
Java applets
Khan Mac-arther
 
Software AG Application Modularity - OSGi and JPMS (Jigsaw)
mfrancis
 
Memory management, Types of memory, Making the most of your RAM.
Megha Sharma
 
TechGIG_Memory leaks in_java_webnair_26th_july_2012
Ashish Bhasin
 
ERP by saeed
Mohd Saeed
 
object oriented programming examples
Abdii Rashid
 
Spring batch overivew
Chanyeong Choi
 
Storage management
Atul Sharma
 
Software Engineering : OOAD using UML
Ajit Nayak
 
0. About this course
IBM Rational software
 
C- language Lecture 4
Hatem Abd El-Salam
 
01 Programming for Problem Solving.pdf
A2Zgameggc
 

More from baabtra.com - No. 1 supplier of quality freshers (20)

PPTX
Agile methodology and scrum development
baabtra.com - No. 1 supplier of quality freshers
 
PDF
Acquiring new skills what you should know
baabtra.com - No. 1 supplier of quality freshers
 
PDF
Baabtra.com programming at school
baabtra.com - No. 1 supplier of quality freshers
 
PDF
99LMS for Enterprises - LMS that you will love
baabtra.com - No. 1 supplier of quality freshers
 
PPTX
Chapter 6 database normalisation
baabtra.com - No. 1 supplier of quality freshers
 
PPTX
Chapter 5 transactions and dcl statements
baabtra.com - No. 1 supplier of quality freshers
 
PPTX
Chapter 4 functions, views, indexing
baabtra.com - No. 1 supplier of quality freshers
 
PPTX
Chapter 3 stored procedures
baabtra.com - No. 1 supplier of quality freshers
 
PPTX
Chapter 2 grouping,scalar and aggergate functions,joins inner join,outer join
baabtra.com - No. 1 supplier of quality freshers
 
PPTX
Chapter 1 introduction to sql server
baabtra.com - No. 1 supplier of quality freshers
 
PPTX
Chapter 1 introduction to sql server
baabtra.com - No. 1 supplier of quality freshers
 
Agile methodology and scrum development
baabtra.com - No. 1 supplier of quality freshers
 
Acquiring new skills what you should know
baabtra.com - No. 1 supplier of quality freshers
 
Baabtra.com programming at school
baabtra.com - No. 1 supplier of quality freshers
 
99LMS for Enterprises - LMS that you will love
baabtra.com - No. 1 supplier of quality freshers
 
Chapter 6 database normalisation
baabtra.com - No. 1 supplier of quality freshers
 
Chapter 5 transactions and dcl statements
baabtra.com - No. 1 supplier of quality freshers
 
Chapter 4 functions, views, indexing
baabtra.com - No. 1 supplier of quality freshers
 
Chapter 2 grouping,scalar and aggergate functions,joins inner join,outer join
baabtra.com - No. 1 supplier of quality freshers
 
Chapter 1 introduction to sql server
baabtra.com - No. 1 supplier of quality freshers
 
Chapter 1 introduction to sql server
baabtra.com - No. 1 supplier of quality freshers
 
Ad

Recently uploaded (20)

PDF
[Newgen] NewgenONE Marvin Brochure 1.pdf
darshakparmar
 
PPTX
UiPath Academic Alliance Educator Panels: Session 2 - Business Analyst Content
DianaGray10
 
PDF
July Patch Tuesday
Ivanti
 
PDF
CIFDAQ Weekly Market Wrap for 11th July 2025
CIFDAQ
 
PPTX
Q2 FY26 Tableau User Group Leader Quarterly Call
lward7
 
PDF
DevBcn - Building 10x Organizations Using Modern Productivity Metrics
Justin Reock
 
PDF
The Builder’s Playbook - 2025 State of AI Report.pdf
jeroen339954
 
PDF
HubSpot Main Hub: A Unified Growth Platform
Jaswinder Singh
 
PDF
Agentic AI lifecycle for Enterprise Hyper-Automation
Debmalya Biswas
 
PPTX
AUTOMATION AND ROBOTICS IN PHARMA INDUSTRY.pptx
sameeraaabegumm
 
PDF
Log-Based Anomaly Detection: Enhancing System Reliability with Machine Learning
Mohammed BEKKOUCHE
 
PDF
Achieving Consistent and Reliable AI Code Generation - Medusa AI
medusaaico
 
PPTX
Building Search Using OpenSearch: Limitations and Workarounds
Sease
 
PPTX
MSP360 Backup Scheduling and Retention Best Practices.pptx
MSP360
 
PDF
NewMind AI - Journal 100 Insights After The 100th Issue
NewMind AI
 
PPTX
OpenID AuthZEN - Analyst Briefing July 2025
David Brossard
 
PDF
SWEBOK Guide and Software Services Engineering Education
Hironori Washizaki
 
PDF
Newgen 2022-Forrester Newgen TEI_13 05 2022-The-Total-Economic-Impact-Newgen-...
darshakparmar
 
PDF
LLMs.txt: Easily Control How AI Crawls Your Site
Keploy
 
PDF
Transcript: New from BookNet Canada for 2025: BNC BiblioShare - Tech Forum 2025
BookNet Canada
 
[Newgen] NewgenONE Marvin Brochure 1.pdf
darshakparmar
 
UiPath Academic Alliance Educator Panels: Session 2 - Business Analyst Content
DianaGray10
 
July Patch Tuesday
Ivanti
 
CIFDAQ Weekly Market Wrap for 11th July 2025
CIFDAQ
 
Q2 FY26 Tableau User Group Leader Quarterly Call
lward7
 
DevBcn - Building 10x Organizations Using Modern Productivity Metrics
Justin Reock
 
The Builder’s Playbook - 2025 State of AI Report.pdf
jeroen339954
 
HubSpot Main Hub: A Unified Growth Platform
Jaswinder Singh
 
Agentic AI lifecycle for Enterprise Hyper-Automation
Debmalya Biswas
 
AUTOMATION AND ROBOTICS IN PHARMA INDUSTRY.pptx
sameeraaabegumm
 
Log-Based Anomaly Detection: Enhancing System Reliability with Machine Learning
Mohammed BEKKOUCHE
 
Achieving Consistent and Reliable AI Code Generation - Medusa AI
medusaaico
 
Building Search Using OpenSearch: Limitations and Workarounds
Sease
 
MSP360 Backup Scheduling and Retention Best Practices.pptx
MSP360
 
NewMind AI - Journal 100 Insights After The 100th Issue
NewMind AI
 
OpenID AuthZEN - Analyst Briefing July 2025
David Brossard
 
SWEBOK Guide and Software Services Engineering Education
Hironori Washizaki
 
Newgen 2022-Forrester Newgen TEI_13 05 2022-The-Total-Economic-Impact-Newgen-...
darshakparmar
 
LLMs.txt: Easily Control How AI Crawls Your Site
Keploy
 
Transcript: New from BookNet Canada for 2025: BNC BiblioShare - Tech Forum 2025
BookNet Canada
 
Ad

Function with heap and stack

  • 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. Week Target Achieved 1 30 23 2 3 Typing Speed
  • 4. Jobs Applied Week Company Designation Applied Date Current Status 1 2 3
  • 5. Functions With Heap and Stack Muhammed Ajmal IK [email protected] www.facebook.com/username twitter.com/username in.linkedin.com/in/profilename 9745020951
  • 6. Overview • Introduction • Stack • Heap • Simple program
  • 7. Introduction • The memory a program uses is typically divided into four different areas: – The code area. – The heap. – The stack
  • 8. Stack • It is a particular portion of memory. • It stores temporary variables created by each function • variables are allocated and freed automatically • the stack has size limits • stack is a last-in, first-out (LIFO) structure
  • 11. Heap • Heap is the area of memory used for dynamic memory allocation • Stored in computer RAM just like the stack. • Function for memory allocation – Malloc() – Calloc() – Realloc()
  • 12. Heap contd. • Variables on the heap must be destroyed manually. • Function for memory deallocation – Free()
  • 15. Find Average of n Number #include<stdio.h> #include<stdlib.h> int main() { int *ptr,n,i; float sum=0.0; printf("Enter how many Element you want to insert"); scanf("%d",&n); ptr=malloc(n*sizeof(int)); if(ptr==NULL)
  • 16. { printf("Memory not allocated"); exit(0); } printf("enter element:"); for(i=0;i<n;++i) { scanf("%d",ptr+i); sum=sum+ *(ptr+i); } printf("n Average %f",(sum/n)); free(ptr); }
  • 18. 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
  • 19. 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] IKK Road, East Hill, Kozhikode Kerala, India. Ph: + 91 – 495 30 63 624 NIT-TBI, NIT Campus, Kozhikode, Kerala, India.