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)

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

More from Swarup Boro (20)

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

Recently uploaded (20)

PPTX
Neurodivergent Friendly Schools - Slides from training session
Pooky Knightsmith
 
PPTX
Identifying elements in the story. Arrange the events in the story
geraldineamahido2
 
PPTX
Quarter 1_PPT_PE & HEALTH 8_WEEK 3-4.pptx
ronajadolpnhs
 
PDF
Dimensions of Societal Planning in Commonism
StefanMz
 
PPTX
EDUCATIONAL MEDIA/ TEACHING AUDIO VISUAL AIDS
Sonali Gupta
 
PPTX
How to Set Up Tags in Odoo 18 - Odoo Slides
Celine George
 
PPTX
How to Create a PDF Report in Odoo 18 - Odoo Slides
Celine George
 
PDF
The History of Phone Numbers in Stoke Newington by Billy Thomas
History of Stoke Newington
 
PPTX
How to Convert an Opportunity into a Quotation in Odoo 18 CRM
Celine George
 
PDF
Reconstruct, Restore, Reimagine: New Perspectives on Stoke Newington’s Histor...
History of Stoke Newington
 
PPTX
Cultivation practice of Litchi in Nepal.pptx
UmeshTimilsina1
 
PDF
Governor Josh Stein letter to NC delegation of U.S. House
Mebane Rash
 
PDF
Stokey: A Jewish Village by Rachel Kolsky
History of Stoke Newington
 
PPTX
grade 5 lesson matatag ENGLISH 5_Q1_PPT_WEEK4.pptx
SireQuinn
 
PDF
Characteristics, Strengths and Weaknesses of Quantitative Research.pdf
Thelma Villaflores
 
PPTX
How to Configure Re-Ordering From Portal in Odoo 18 Website
Celine George
 
PDF
The Constitution Review Committee (CRC) has released an updated schedule for ...
nservice241
 
PPTX
CATEGORIES OF NURSING PERSONNEL: HOSPITAL & COLLEGE
PRADEEP ABOTHU
 
PDF
Horarios de distribución de agua en julio
pegazohn1978
 
PDF
DIGESTION OF CARBOHYDRATES,PROTEINS,LIPIDS
raviralanaresh2
 
Neurodivergent Friendly Schools - Slides from training session
Pooky Knightsmith
 
Identifying elements in the story. Arrange the events in the story
geraldineamahido2
 
Quarter 1_PPT_PE & HEALTH 8_WEEK 3-4.pptx
ronajadolpnhs
 
Dimensions of Societal Planning in Commonism
StefanMz
 
EDUCATIONAL MEDIA/ TEACHING AUDIO VISUAL AIDS
Sonali Gupta
 
How to Set Up Tags in Odoo 18 - Odoo Slides
Celine George
 
How to Create a PDF Report in Odoo 18 - Odoo Slides
Celine George
 
The History of Phone Numbers in Stoke Newington by Billy Thomas
History of Stoke Newington
 
How to Convert an Opportunity into a Quotation in Odoo 18 CRM
Celine George
 
Reconstruct, Restore, Reimagine: New Perspectives on Stoke Newington’s Histor...
History of Stoke Newington
 
Cultivation practice of Litchi in Nepal.pptx
UmeshTimilsina1
 
Governor Josh Stein letter to NC delegation of U.S. House
Mebane Rash
 
Stokey: A Jewish Village by Rachel Kolsky
History of Stoke Newington
 
grade 5 lesson matatag ENGLISH 5_Q1_PPT_WEEK4.pptx
SireQuinn
 
Characteristics, Strengths and Weaknesses of Quantitative Research.pdf
Thelma Villaflores
 
How to Configure Re-Ordering From Portal in Odoo 18 Website
Celine George
 
The Constitution Review Committee (CRC) has released an updated schedule for ...
nservice241
 
CATEGORIES OF NURSING PERSONNEL: HOSPITAL & COLLEGE
PRADEEP ABOTHU
 
Horarios de distribución de agua en julio
pegazohn1978
 
DIGESTION OF CARBOHYDRATES,PROTEINS,LIPIDS
raviralanaresh2
 
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); }