SlideShare a Scribd company logo
/*
Program to print array elements using recursion
*/
#include<iostream>
using namespace std;
void f(int p[], int q, int r);
main()
{
int a[10],i,n,o;
cout<<"n Enter the number of elements";
cin>>n;
cout<<"n Enter the array elements";
for(i=0;i<n;i++)
cin>>a[i];
cout<<"nThe array elements are";
f(a,n,o);
}
void f(int p[], int q, int r)
{
if(r==q)
return;
else
cout<<" "<<p[r];
r++;
f(p,q,r);
}

More Related Content

What's hot (18)

Write a program that calculate the no of prime no,even and odd no.
Write a program that calculate the no of prime no,even and odd no.
university of Gujrat, pakistan
 
Sol7
Sol7
University Of Lahore
 
Pratik Bakane C++
Pratik Bakane C++
pratikbakane
 
C programs Set 2
C programs Set 2
Koshy Geoji
 
Pratik Bakane C++
Pratik Bakane C++
pratikbakane
 
Pratik Bakane C++
Pratik Bakane C++
pratikbakane
 
Bankers Algo Implementation
Bankers Algo Implementation
Deepak Agarwal
 
Document
Document
AjitRaj12
 
Unit 1 of c++ first program
Unit 1 of c++ first program
AKR Education
 
Practical no 2
Practical no 2
Kshitija Dalvi
 
Conversion of data types in java
Conversion of data types in java
One97 Communications Limited
 
gd
gd
phuong Ho
 
2 18-2018-all teams total runs
2 18-2018-all teams total runs
Alexander Bitar
 
2 19-2018-mean of all runs
2 19-2018-mean of all runs
Alexander Bitar
 
Java Code for Sample Projects Methods
Java Code for Sample Projects Methods
jwjablonski
 
F(2)
F(2)
lukman abbas
 
test
test
marenostrumad
 
Ooprc3c
Ooprc3c
Ankit Dubey
 

More from Swarup Boro (20)

Concatenation of two strings using class in c++
Concatenation of two strings using class in c++
Swarup Boro
 
Program: Inheritance in Class - to find topper out of 10 students
Program: Inheritance in Class - to find topper out of 10 students
Swarup Boro
 
Binary addition using class concept in c++
Binary addition using class concept in c++
Swarup Boro
 
Study of Diffusion of solids in Liquids
Study of Diffusion of solids in Liquids
Swarup Boro
 
Program using function overloading
Program using function overloading
Swarup Boro
 
Program to sort array using insertion sort
Program to sort array using insertion sort
Swarup Boro
 
Program to find the avg of two numbers
Program to find the avg of two numbers
Swarup Boro
 
Canteen management program
Canteen management program
Swarup Boro
 
C++ program using class
C++ program using class
Swarup Boro
 
Railway reservation
Railway reservation
Swarup Boro
 
Boolean
Boolean
Swarup Boro
 
Classes
Classes
Swarup Boro
 
Constructor & destructor
Constructor & destructor
Swarup Boro
 
Arrays and library functions
Arrays and library functions
Swarup Boro
 
Pointers
Pointers
Swarup Boro
 
Queue
Queue
Swarup Boro
 
Structures in c++
Structures in c++
Swarup Boro
 
Stack
Stack
Swarup Boro
 
Functions
Functions
Swarup Boro
 
Implementation of oop concept in c++
Implementation of oop concept in c++
Swarup Boro
 
Concatenation of two strings using class in c++
Concatenation of two strings using class in c++
Swarup Boro
 
Program: Inheritance in Class - to find topper out of 10 students
Program: Inheritance in Class - to find topper out of 10 students
Swarup Boro
 
Binary addition using class concept in c++
Binary addition using class concept in c++
Swarup Boro
 
Study of Diffusion of solids in Liquids
Study of Diffusion of solids in Liquids
Swarup Boro
 
Program using function overloading
Program using function overloading
Swarup Boro
 
Program to sort array using insertion sort
Program to sort array using insertion sort
Swarup Boro
 
Program to find the avg of two numbers
Program to find the avg of two numbers
Swarup Boro
 
Canteen management program
Canteen management program
Swarup Boro
 
C++ program using class
C++ program using class
Swarup Boro
 
Railway reservation
Railway reservation
Swarup Boro
 
Constructor & destructor
Constructor & destructor
Swarup Boro
 
Arrays and library functions
Arrays and library functions
Swarup Boro
 
Structures in c++
Structures in c++
Swarup Boro
 
Implementation of oop concept in c++
Implementation of oop concept in c++
Swarup Boro
 
Ad

Recently uploaded (20)

Vikas Bansal Himachal Pradesh: A Visionary Transforming Himachal’s Educationa...
Vikas Bansal Himachal Pradesh: A Visionary Transforming Himachal’s Educationa...
Himalayan Group of Professional Institutions (HGPI)
 
ABCs of Bookkeeping for Nonprofits TechSoup.pdf
ABCs of Bookkeeping for Nonprofits TechSoup.pdf
TechSoup
 
How to Manage & Create a New Department in Odoo 18 Employee
How to Manage & Create a New Department in Odoo 18 Employee
Celine George
 
Sustainable Innovation with Immersive Learning
Sustainable Innovation with Immersive Learning
Leonel Morgado
 
Black and White Illustrative Group Project Presentation.pdf (1).pdf
Black and White Illustrative Group Project Presentation.pdf (1).pdf
AnnasofiaUrsini
 
Ray Dalio How Countries go Broke the Big Cycle
Ray Dalio How Countries go Broke the Big Cycle
Dadang Solihin
 
Basic English for Communication - Dr Hj Euis Eti Rohaeti Mpd
Basic English for Communication - Dr Hj Euis Eti Rohaeti Mpd
Restu Bias Primandhika
 
PEST OF WHEAT SORGHUM BAJRA and MINOR MILLETS.pptx
PEST OF WHEAT SORGHUM BAJRA and MINOR MILLETS.pptx
Arshad Shaikh
 
GEOGRAPHY-Study Material [ Class 10th] .pdf
GEOGRAPHY-Study Material [ Class 10th] .pdf
SHERAZ AHMAD LONE
 
The Man In The Back – Exceptional Delaware.pdf
The Man In The Back – Exceptional Delaware.pdf
dennisongomezk
 
Analysis of Quantitative Data Parametric and non-parametric tests.pptx
Analysis of Quantitative Data Parametric and non-parametric tests.pptx
Shrutidhara2
 
BINARY files CSV files JSON files with example.pptx
BINARY files CSV files JSON files with example.pptx
Ramakrishna Reddy Bijjam
 
Paper 108 | Thoreau’s Influence on Gandhi: The Evolution of Civil Disobedience
Paper 108 | Thoreau’s Influence on Gandhi: The Evolution of Civil Disobedience
Rajdeep Bavaliya
 
Final Sketch Designs for poster production.pptx
Final Sketch Designs for poster production.pptx
bobby205207
 
LDMMIA GRAD Student Check-in Orientation Sampler
LDMMIA GRAD Student Check-in Orientation Sampler
LDM & Mia eStudios
 
Overview of Employee in Odoo 18 - Odoo Slides
Overview of Employee in Odoo 18 - Odoo Slides
Celine George
 
LDMMIA Spring Ending Guest Grad Student News
LDMMIA Spring Ending Guest Grad Student News
LDM & Mia eStudios
 
Energy Balances Of Oecd Countries 2011 Iea Statistics 1st Edition Oecd
Energy Balances Of Oecd Countries 2011 Iea Statistics 1st Edition Oecd
razelitouali
 
How to Create an Event in Odoo 18 - Odoo 18 Slides
How to Create an Event in Odoo 18 - Odoo 18 Slides
Celine George
 
FEBA Sofia Univercity final diplian v3 GSDG 5.2025.pdf
FEBA Sofia Univercity final diplian v3 GSDG 5.2025.pdf
ChristinaFortunova
 
ABCs of Bookkeeping for Nonprofits TechSoup.pdf
ABCs of Bookkeeping for Nonprofits TechSoup.pdf
TechSoup
 
How to Manage & Create a New Department in Odoo 18 Employee
How to Manage & Create a New Department in Odoo 18 Employee
Celine George
 
Sustainable Innovation with Immersive Learning
Sustainable Innovation with Immersive Learning
Leonel Morgado
 
Black and White Illustrative Group Project Presentation.pdf (1).pdf
Black and White Illustrative Group Project Presentation.pdf (1).pdf
AnnasofiaUrsini
 
Ray Dalio How Countries go Broke the Big Cycle
Ray Dalio How Countries go Broke the Big Cycle
Dadang Solihin
 
Basic English for Communication - Dr Hj Euis Eti Rohaeti Mpd
Basic English for Communication - Dr Hj Euis Eti Rohaeti Mpd
Restu Bias Primandhika
 
PEST OF WHEAT SORGHUM BAJRA and MINOR MILLETS.pptx
PEST OF WHEAT SORGHUM BAJRA and MINOR MILLETS.pptx
Arshad Shaikh
 
GEOGRAPHY-Study Material [ Class 10th] .pdf
GEOGRAPHY-Study Material [ Class 10th] .pdf
SHERAZ AHMAD LONE
 
The Man In The Back – Exceptional Delaware.pdf
The Man In The Back – Exceptional Delaware.pdf
dennisongomezk
 
Analysis of Quantitative Data Parametric and non-parametric tests.pptx
Analysis of Quantitative Data Parametric and non-parametric tests.pptx
Shrutidhara2
 
BINARY files CSV files JSON files with example.pptx
BINARY files CSV files JSON files with example.pptx
Ramakrishna Reddy Bijjam
 
Paper 108 | Thoreau’s Influence on Gandhi: The Evolution of Civil Disobedience
Paper 108 | Thoreau’s Influence on Gandhi: The Evolution of Civil Disobedience
Rajdeep Bavaliya
 
Final Sketch Designs for poster production.pptx
Final Sketch Designs for poster production.pptx
bobby205207
 
LDMMIA GRAD Student Check-in Orientation Sampler
LDMMIA GRAD Student Check-in Orientation Sampler
LDM & Mia eStudios
 
Overview of Employee in Odoo 18 - Odoo Slides
Overview of Employee in Odoo 18 - Odoo Slides
Celine George
 
LDMMIA Spring Ending Guest Grad Student News
LDMMIA Spring Ending Guest Grad Student News
LDM & Mia eStudios
 
Energy Balances Of Oecd Countries 2011 Iea Statistics 1st Edition Oecd
Energy Balances Of Oecd Countries 2011 Iea Statistics 1st Edition Oecd
razelitouali
 
How to Create an Event in Odoo 18 - Odoo 18 Slides
How to Create an Event in Odoo 18 - Odoo 18 Slides
Celine George
 
FEBA Sofia Univercity final diplian v3 GSDG 5.2025.pdf
FEBA Sofia Univercity final diplian v3 GSDG 5.2025.pdf
ChristinaFortunova
 
Ad

Array using recursion

  • 1. /* Program to print array elements using recursion */ #include<iostream> using namespace std; void f(int p[], int q, int r); main() { int a[10],i,n,o; cout<<"n Enter the number of elements"; cin>>n; cout<<"n Enter the array elements"; for(i=0;i<n;i++) cin>>a[i]; cout<<"nThe array elements are"; f(a,n,o); } void f(int p[], int q, int r) { if(r==q) return; else cout<<" "<<p[r]; r++; f(p,q,r); }