SlideShare a Scribd company logo
1 of 12
Technical Chat
C Workshop
Day- 6
extern int g=5;
void abc()
{
int a;
static int s=5;
a=s--;
++g;
printf(“n %d %d %d”, a,s,g);
if(a>=3)
abc();
printf(“n %d %d %d”, a,s,g);
}
void xyz()
{
auto int a;
static int s;
a=++s;
--g;
printf(“n %d %d %d”, a,s,g);
if(a<=3)
xyz();
printf(“n %d %d %d”, a,s,g);
}
void main()
{
void xyz(void);
xyz();
abc();
}
O/p-
1 1 4
2 2 3
3 3 2
4 4 1
4 4 1
3 4 1
2 4 1
1 4 1
5 4 2
4 3 3
3 2 4
2 1 5
2 1 5
3 1 5
4 1 5
5 1 5
Classification of Recursion
● Internal Recursion Process
● External Recursion Process
● Whenever a recursion function is calling itself
then it is called internal recursion process.
● When one recursion function is calling another
recursion function then it is called external
recursion process.
extern int g=5;
void abc()
{
auto int a;
static int s=5;
a=s--;
++g;
printf(“n %d %d %d”, a,s,g);
if(a>=3)
abc();
printf(“%d %d %d”, a,s,g);
}
void main()
{
void xyz(void);
xyz();
}
void xyz()
{
int a;
static int s;
a=s++;
--g;
printf(“n %d %d %d”, a,s,g);
if(a<=1)
{
abc();
xyz();
}
printf(“n %d %d %d”, a,s,g);
}
O/p-
0 1 4
5 4 5
4 3 6
3 2 7
2 1 8
2 1 8
3 1 8
4 1 8
5 1 8
1 2 7
1 0 8
1 0 8
2 3 7
2 3 7
1 3 7
0 3 7
recursion by using main()
● By using auto variable it became stack overflow
● Because for every call auto variable will be
constructed.
void main()
{
int a= 5;
++a;
printf(“%d”, a);
if (a<=6)
main();
printf(“%d”,a);
}
O/p-
6666666666.........Stack overflow
void main()
{
static int s=2;
++s;
printf(“%d”,s);
if(s<=4)
main()
printf(“%d”,s);
}
O/p- 235555
Power of a number through recursion:
int power(int b, int e)
{
if (e<0)
return 0;
else if(e==0)
return 1;
else
return(b*power(b-e-1));
}
void main()
{
int a,b,p;
printf(“Enter value of a:”);
scanf(“%d”, &a);
printf(“Enter value of b:”);
scnaf(“%d”, &b);
p=power(a,b);
printf(“n %d^%d value is :
%d”, a,b,p);
}
Factorial through recursion.
void main()
{
int n,f;
int fact(int);
printf(“Enter a value:”);
scanf(“%d”, &n);
f=fact(n);
printf(“n %d fact value is: %d”,n,f);
}
int fact(int n)
{
if(n<0)
return 0;
else if(n<=1)
return 1;
else
return (n*fact(n-1));
}
Dangling Pointer
● A pointer variable which is pointing to a
dead or inactive location, is called
dangling pointer.
Function pointer
● A pointer variable which holds the address of the
function, is called function pointer.
● Function pointer calls are faster then normal
function calls.
● By using function pointer it is possible to pass a
function as a argument to another function.

More Related Content

What's hot (20)

Pratik Bakane C++
Pratik Bakane C++Pratik Bakane C++
Pratik Bakane C++
 
Bcsl 033 data and file structures lab s2-2
Bcsl 033 data and file structures lab s2-2Bcsl 033 data and file structures lab s2-2
Bcsl 033 data and file structures lab s2-2
 
Bcsl 033 data and file structures lab s3-3
Bcsl 033 data and file structures lab s3-3Bcsl 033 data and file structures lab s3-3
Bcsl 033 data and file structures lab s3-3
 
Avl tree
Avl treeAvl tree
Avl tree
 
Data Structures Practical File
Data Structures Practical File Data Structures Practical File
Data Structures Practical File
 
C언어 스터디 강의자료 - 1차시
C언어 스터디 강의자료 - 1차시C언어 스터디 강의자료 - 1차시
C언어 스터디 강의자료 - 1차시
 
Bcsl 033 data and file structures lab s1-1
Bcsl 033 data and file structures lab s1-1Bcsl 033 data and file structures lab s1-1
Bcsl 033 data and file structures lab s1-1
 
week-4x
week-4xweek-4x
week-4x
 
Data Structures Using C Practical File
Data Structures Using C Practical File Data Structures Using C Practical File
Data Structures Using C Practical File
 
Runge kutta C programme
Runge kutta C programmeRunge kutta C programme
Runge kutta C programme
 
2 d rotation
2 d rotation2 d rotation
2 d rotation
 
C Programming Example
C Programming ExampleC Programming Example
C Programming Example
 
C++ programs
C++ programsC++ programs
C++ programs
 
C mcq practice test 2
C mcq practice test 2C mcq practice test 2
C mcq practice test 2
 
programs
programsprograms
programs
 
Shan
ShanShan
Shan
 
C Programming Example
C Programming Example C Programming Example
C Programming Example
 
Logic development
Logic developmentLogic development
Logic development
 
Session06 functions
Session06 functionsSession06 functions
Session06 functions
 
Spiral array
Spiral arraySpiral array
Spiral array
 

Viewers also liked

Viewers also liked (18)

Pai 3-03
Pai 3-03Pai 3-03
Pai 3-03
 
Interacciones o looping scratch
Interacciones o looping scratchInteracciones o looping scratch
Interacciones o looping scratch
 
Goldman Presentation June 2014
Goldman Presentation June 2014Goldman Presentation June 2014
Goldman Presentation June 2014
 
Tu bishvat
Tu bishvatTu bishvat
Tu bishvat
 
What is css
What   is   cssWhat   is   css
What is css
 
Malak
MalakMalak
Malak
 
VoyVoy Overview
VoyVoy OverviewVoyVoy Overview
VoyVoy Overview
 
VoyVoy Look Book 2014
VoyVoy Look Book 2014VoyVoy Look Book 2014
VoyVoy Look Book 2014
 
Present Simple
Present SimplePresent Simple
Present Simple
 
C workshop day 7
C workshop day 7C workshop day 7
C workshop day 7
 
Coooooool
CooooooolCoooooool
Coooooool
 
Kartofel erglis daniel
Kartofel erglis danielKartofel erglis daniel
Kartofel erglis daniel
 
Physical geography of canada
Physical geography of canadaPhysical geography of canada
Physical geography of canada
 
November 2014 Investor Presentation
November 2014 Investor PresentationNovember 2014 Investor Presentation
November 2014 Investor Presentation
 
November Investor Presentation
November Investor PresentationNovember Investor Presentation
November Investor Presentation
 
1605 fun investor presentation
1605 fun investor presentation1605 fun investor presentation
1605 fun investor presentation
 
1512 december investor presentation
1512 december investor presentation1512 december investor presentation
1512 december investor presentation
 
1609 fun investor presentation
1609 fun investor presentation1609 fun investor presentation
1609 fun investor presentation
 

Similar to C workshop day 6 (20)

C tech questions
C tech questionsC tech questions
C tech questions
 
C Programming lab
C Programming labC Programming lab
C Programming lab
 
#2
#2#2
#2
 
Vcs16
Vcs16Vcs16
Vcs16
 
C programming BY Mazedur
C programming BY MazedurC programming BY Mazedur
C programming BY Mazedur
 
DataStructures notes
DataStructures notesDataStructures notes
DataStructures notes
 
LET US C (5th EDITION) CHAPTER 2 ANSWERS
LET US C (5th EDITION) CHAPTER 2 ANSWERSLET US C (5th EDITION) CHAPTER 2 ANSWERS
LET US C (5th EDITION) CHAPTER 2 ANSWERS
 
C basics
C basicsC basics
C basics
 
Assignment on Numerical Method C Code
Assignment on Numerical Method C CodeAssignment on Numerical Method C Code
Assignment on Numerical Method C Code
 
Vcs23
Vcs23Vcs23
Vcs23
 
9.C Programming
9.C Programming9.C Programming
9.C Programming
 
lets play with "c"..!!! :):)
lets play with "c"..!!! :):)lets play with "c"..!!! :):)
lets play with "c"..!!! :):)
 
Automata fix.pdf
Automata fix.pdfAutomata fix.pdf
Automata fix.pdf
 
Cpd lecture im 207
Cpd lecture im 207Cpd lecture im 207
Cpd lecture im 207
 
Bti1022 lab sheet 8
Bti1022 lab sheet 8Bti1022 lab sheet 8
Bti1022 lab sheet 8
 
Bti1022 lab sheet 8
Bti1022 lab sheet 8Bti1022 lab sheet 8
Bti1022 lab sheet 8
 
C lab manaual
C lab manaualC lab manaual
C lab manaual
 
LET US C (5th EDITION) CHAPTER 4 ANSWERS
LET US C (5th EDITION) CHAPTER 4 ANSWERSLET US C (5th EDITION) CHAPTER 4 ANSWERS
LET US C (5th EDITION) CHAPTER 4 ANSWERS
 
Cpds lab
Cpds labCpds lab
Cpds lab
 
Solutionsfor co2 C Programs for data structures
Solutionsfor co2 C Programs for data structuresSolutionsfor co2 C Programs for data structures
Solutionsfor co2 C Programs for data structures
 

Recently uploaded

How to Add Barcode on PDF Report in Odoo 17
How to Add Barcode on PDF Report in Odoo 17How to Add Barcode on PDF Report in Odoo 17
How to Add Barcode on PDF Report in Odoo 17Celine George
 
Incoming and Outgoing Shipments in 3 STEPS Using Odoo 17
Incoming and Outgoing Shipments in 3 STEPS Using Odoo 17Incoming and Outgoing Shipments in 3 STEPS Using Odoo 17
Incoming and Outgoing Shipments in 3 STEPS Using Odoo 17Celine George
 
USPS® Forced Meter Migration - How to Know if Your Postage Meter Will Soon be...
USPS® Forced Meter Migration - How to Know if Your Postage Meter Will Soon be...USPS® Forced Meter Migration - How to Know if Your Postage Meter Will Soon be...
USPS® Forced Meter Migration - How to Know if Your Postage Meter Will Soon be...Postal Advocate Inc.
 
ECONOMIC CONTEXT - PAPER 1 Q3: NEWSPAPERS.pptx
ECONOMIC CONTEXT - PAPER 1 Q3: NEWSPAPERS.pptxECONOMIC CONTEXT - PAPER 1 Q3: NEWSPAPERS.pptx
ECONOMIC CONTEXT - PAPER 1 Q3: NEWSPAPERS.pptxiammrhaywood
 
MULTIDISCIPLINRY NATURE OF THE ENVIRONMENTAL STUDIES.pptx
MULTIDISCIPLINRY NATURE OF THE ENVIRONMENTAL STUDIES.pptxMULTIDISCIPLINRY NATURE OF THE ENVIRONMENTAL STUDIES.pptx
MULTIDISCIPLINRY NATURE OF THE ENVIRONMENTAL STUDIES.pptxAnupkumar Sharma
 
ANG SEKTOR NG agrikultura.pptx QUARTER 4
ANG SEKTOR NG agrikultura.pptx QUARTER 4ANG SEKTOR NG agrikultura.pptx QUARTER 4
ANG SEKTOR NG agrikultura.pptx QUARTER 4MiaBumagat1
 
Field Attribute Index Feature in Odoo 17
Field Attribute Index Feature in Odoo 17Field Attribute Index Feature in Odoo 17
Field Attribute Index Feature in Odoo 17Celine George
 
ISYU TUNGKOL SA SEKSWLADIDA (ISSUE ABOUT SEXUALITY
ISYU TUNGKOL SA SEKSWLADIDA (ISSUE ABOUT SEXUALITYISYU TUNGKOL SA SEKSWLADIDA (ISSUE ABOUT SEXUALITY
ISYU TUNGKOL SA SEKSWLADIDA (ISSUE ABOUT SEXUALITYKayeClaireEstoconing
 
Grade 9 Quarter 4 Dll Grade 9 Quarter 4 DLL.pdf
Grade 9 Quarter 4 Dll Grade 9 Quarter 4 DLL.pdfGrade 9 Quarter 4 Dll Grade 9 Quarter 4 DLL.pdf
Grade 9 Quarter 4 Dll Grade 9 Quarter 4 DLL.pdfJemuel Francisco
 
GRADE 4 - SUMMATIVE TEST QUARTER 4 ALL SUBJECTS
GRADE 4 - SUMMATIVE TEST QUARTER 4 ALL SUBJECTSGRADE 4 - SUMMATIVE TEST QUARTER 4 ALL SUBJECTS
GRADE 4 - SUMMATIVE TEST QUARTER 4 ALL SUBJECTSJoshuaGantuangco2
 
4.16.24 Poverty and Precarity--Desmond.pptx
4.16.24 Poverty and Precarity--Desmond.pptx4.16.24 Poverty and Precarity--Desmond.pptx
4.16.24 Poverty and Precarity--Desmond.pptxmary850239
 
Q4-PPT-Music9_Lesson-1-Romantic-Opera.pptx
Q4-PPT-Music9_Lesson-1-Romantic-Opera.pptxQ4-PPT-Music9_Lesson-1-Romantic-Opera.pptx
Q4-PPT-Music9_Lesson-1-Romantic-Opera.pptxlancelewisportillo
 
What is Model Inheritance in Odoo 17 ERP
What is Model Inheritance in Odoo 17 ERPWhat is Model Inheritance in Odoo 17 ERP
What is Model Inheritance in Odoo 17 ERPCeline George
 
4.16.24 21st Century Movements for Black Lives.pptx
4.16.24 21st Century Movements for Black Lives.pptx4.16.24 21st Century Movements for Black Lives.pptx
4.16.24 21st Century Movements for Black Lives.pptxmary850239
 
Food processing presentation for bsc agriculture hons
Food processing presentation for bsc agriculture honsFood processing presentation for bsc agriculture hons
Food processing presentation for bsc agriculture honsManeerUddin
 
INTRODUCTION TO CATHOLIC CHRISTOLOGY.pptx
INTRODUCTION TO CATHOLIC CHRISTOLOGY.pptxINTRODUCTION TO CATHOLIC CHRISTOLOGY.pptx
INTRODUCTION TO CATHOLIC CHRISTOLOGY.pptxHumphrey A Beña
 
THEORIES OF ORGANIZATION-PUBLIC ADMINISTRATION
THEORIES OF ORGANIZATION-PUBLIC ADMINISTRATIONTHEORIES OF ORGANIZATION-PUBLIC ADMINISTRATION
THEORIES OF ORGANIZATION-PUBLIC ADMINISTRATIONHumphrey A Beña
 

Recently uploaded (20)

How to Add Barcode on PDF Report in Odoo 17
How to Add Barcode on PDF Report in Odoo 17How to Add Barcode on PDF Report in Odoo 17
How to Add Barcode on PDF Report in Odoo 17
 
Incoming and Outgoing Shipments in 3 STEPS Using Odoo 17
Incoming and Outgoing Shipments in 3 STEPS Using Odoo 17Incoming and Outgoing Shipments in 3 STEPS Using Odoo 17
Incoming and Outgoing Shipments in 3 STEPS Using Odoo 17
 
USPS® Forced Meter Migration - How to Know if Your Postage Meter Will Soon be...
USPS® Forced Meter Migration - How to Know if Your Postage Meter Will Soon be...USPS® Forced Meter Migration - How to Know if Your Postage Meter Will Soon be...
USPS® Forced Meter Migration - How to Know if Your Postage Meter Will Soon be...
 
ECONOMIC CONTEXT - PAPER 1 Q3: NEWSPAPERS.pptx
ECONOMIC CONTEXT - PAPER 1 Q3: NEWSPAPERS.pptxECONOMIC CONTEXT - PAPER 1 Q3: NEWSPAPERS.pptx
ECONOMIC CONTEXT - PAPER 1 Q3: NEWSPAPERS.pptx
 
MULTIDISCIPLINRY NATURE OF THE ENVIRONMENTAL STUDIES.pptx
MULTIDISCIPLINRY NATURE OF THE ENVIRONMENTAL STUDIES.pptxMULTIDISCIPLINRY NATURE OF THE ENVIRONMENTAL STUDIES.pptx
MULTIDISCIPLINRY NATURE OF THE ENVIRONMENTAL STUDIES.pptx
 
ANG SEKTOR NG agrikultura.pptx QUARTER 4
ANG SEKTOR NG agrikultura.pptx QUARTER 4ANG SEKTOR NG agrikultura.pptx QUARTER 4
ANG SEKTOR NG agrikultura.pptx QUARTER 4
 
Field Attribute Index Feature in Odoo 17
Field Attribute Index Feature in Odoo 17Field Attribute Index Feature in Odoo 17
Field Attribute Index Feature in Odoo 17
 
ISYU TUNGKOL SA SEKSWLADIDA (ISSUE ABOUT SEXUALITY
ISYU TUNGKOL SA SEKSWLADIDA (ISSUE ABOUT SEXUALITYISYU TUNGKOL SA SEKSWLADIDA (ISSUE ABOUT SEXUALITY
ISYU TUNGKOL SA SEKSWLADIDA (ISSUE ABOUT SEXUALITY
 
Grade 9 Quarter 4 Dll Grade 9 Quarter 4 DLL.pdf
Grade 9 Quarter 4 Dll Grade 9 Quarter 4 DLL.pdfGrade 9 Quarter 4 Dll Grade 9 Quarter 4 DLL.pdf
Grade 9 Quarter 4 Dll Grade 9 Quarter 4 DLL.pdf
 
GRADE 4 - SUMMATIVE TEST QUARTER 4 ALL SUBJECTS
GRADE 4 - SUMMATIVE TEST QUARTER 4 ALL SUBJECTSGRADE 4 - SUMMATIVE TEST QUARTER 4 ALL SUBJECTS
GRADE 4 - SUMMATIVE TEST QUARTER 4 ALL SUBJECTS
 
LEFT_ON_C'N_ PRELIMS_EL_DORADO_2024.pptx
LEFT_ON_C'N_ PRELIMS_EL_DORADO_2024.pptxLEFT_ON_C'N_ PRELIMS_EL_DORADO_2024.pptx
LEFT_ON_C'N_ PRELIMS_EL_DORADO_2024.pptx
 
4.16.24 Poverty and Precarity--Desmond.pptx
4.16.24 Poverty and Precarity--Desmond.pptx4.16.24 Poverty and Precarity--Desmond.pptx
4.16.24 Poverty and Precarity--Desmond.pptx
 
Q4-PPT-Music9_Lesson-1-Romantic-Opera.pptx
Q4-PPT-Music9_Lesson-1-Romantic-Opera.pptxQ4-PPT-Music9_Lesson-1-Romantic-Opera.pptx
Q4-PPT-Music9_Lesson-1-Romantic-Opera.pptx
 
FINALS_OF_LEFT_ON_C'N_EL_DORADO_2024.pptx
FINALS_OF_LEFT_ON_C'N_EL_DORADO_2024.pptxFINALS_OF_LEFT_ON_C'N_EL_DORADO_2024.pptx
FINALS_OF_LEFT_ON_C'N_EL_DORADO_2024.pptx
 
What is Model Inheritance in Odoo 17 ERP
What is Model Inheritance in Odoo 17 ERPWhat is Model Inheritance in Odoo 17 ERP
What is Model Inheritance in Odoo 17 ERP
 
4.16.24 21st Century Movements for Black Lives.pptx
4.16.24 21st Century Movements for Black Lives.pptx4.16.24 21st Century Movements for Black Lives.pptx
4.16.24 21st Century Movements for Black Lives.pptx
 
Food processing presentation for bsc agriculture hons
Food processing presentation for bsc agriculture honsFood processing presentation for bsc agriculture hons
Food processing presentation for bsc agriculture hons
 
YOUVE_GOT_EMAIL_PRELIMS_EL_DORADO_2024.pptx
YOUVE_GOT_EMAIL_PRELIMS_EL_DORADO_2024.pptxYOUVE_GOT_EMAIL_PRELIMS_EL_DORADO_2024.pptx
YOUVE_GOT_EMAIL_PRELIMS_EL_DORADO_2024.pptx
 
INTRODUCTION TO CATHOLIC CHRISTOLOGY.pptx
INTRODUCTION TO CATHOLIC CHRISTOLOGY.pptxINTRODUCTION TO CATHOLIC CHRISTOLOGY.pptx
INTRODUCTION TO CATHOLIC CHRISTOLOGY.pptx
 
THEORIES OF ORGANIZATION-PUBLIC ADMINISTRATION
THEORIES OF ORGANIZATION-PUBLIC ADMINISTRATIONTHEORIES OF ORGANIZATION-PUBLIC ADMINISTRATION
THEORIES OF ORGANIZATION-PUBLIC ADMINISTRATION
 

C workshop day 6

  • 2. extern int g=5; void abc() { int a; static int s=5; a=s--; ++g; printf(“n %d %d %d”, a,s,g); if(a>=3) abc(); printf(“n %d %d %d”, a,s,g); } void xyz() { auto int a; static int s; a=++s; --g; printf(“n %d %d %d”, a,s,g); if(a<=3) xyz(); printf(“n %d %d %d”, a,s,g); } void main() { void xyz(void); xyz(); abc(); }
  • 3. O/p- 1 1 4 2 2 3 3 3 2 4 4 1 4 4 1 3 4 1 2 4 1 1 4 1 5 4 2 4 3 3 3 2 4 2 1 5 2 1 5 3 1 5 4 1 5 5 1 5
  • 4. Classification of Recursion ● Internal Recursion Process ● External Recursion Process ● Whenever a recursion function is calling itself then it is called internal recursion process. ● When one recursion function is calling another recursion function then it is called external recursion process.
  • 5. extern int g=5; void abc() { auto int a; static int s=5; a=s--; ++g; printf(“n %d %d %d”, a,s,g); if(a>=3) abc(); printf(“%d %d %d”, a,s,g); } void main() { void xyz(void); xyz(); } void xyz() { int a; static int s; a=s++; --g; printf(“n %d %d %d”, a,s,g); if(a<=1) { abc(); xyz(); } printf(“n %d %d %d”, a,s,g); }
  • 6. O/p- 0 1 4 5 4 5 4 3 6 3 2 7 2 1 8 2 1 8 3 1 8 4 1 8 5 1 8 1 2 7 1 0 8 1 0 8 2 3 7 2 3 7 1 3 7 0 3 7
  • 7. recursion by using main() ● By using auto variable it became stack overflow ● Because for every call auto variable will be constructed. void main() { int a= 5; ++a; printf(“%d”, a); if (a<=6) main(); printf(“%d”,a); } O/p- 6666666666.........Stack overflow
  • 8. void main() { static int s=2; ++s; printf(“%d”,s); if(s<=4) main() printf(“%d”,s); } O/p- 235555
  • 9. Power of a number through recursion: int power(int b, int e) { if (e<0) return 0; else if(e==0) return 1; else return(b*power(b-e-1)); } void main() { int a,b,p; printf(“Enter value of a:”); scanf(“%d”, &a); printf(“Enter value of b:”); scnaf(“%d”, &b); p=power(a,b); printf(“n %d^%d value is : %d”, a,b,p); }
  • 10. Factorial through recursion. void main() { int n,f; int fact(int); printf(“Enter a value:”); scanf(“%d”, &n); f=fact(n); printf(“n %d fact value is: %d”,n,f); } int fact(int n) { if(n<0) return 0; else if(n<=1) return 1; else return (n*fact(n-1)); }
  • 11. Dangling Pointer ● A pointer variable which is pointing to a dead or inactive location, is called dangling pointer.
  • 12. Function pointer ● A pointer variable which holds the address of the function, is called function pointer. ● Function pointer calls are faster then normal function calls. ● By using function pointer it is possible to pass a function as a argument to another function.