THE UNIVERSITY OF DODOMA
College Of Informatics and Virtual Education
NAME: Makame, Makame H REGISTRATION No: T/UDOM/2010/00410 PROGRAM: B Sc. Computer and Information Security
ASSIGNMENT NO.3
COURSE NAME: Data structure and algorithm
COURSE CODE: CS 104 COUSE INSTRUCTOR: Masoud Masoud
Question: Write a program of getting a stuck using recursive method
Program #include<iostream.h> #include<conio.h>
int i=0; char stk[9];
int pop(int count) {
if(count==0&&(i>0)) { cout<<stk[--i] <<"\t"; return pop(0); } else { if(count>=0) { cin>>stk[i++]; return pop(count-1); } }
}
void main() { int size;
cout<<"Enter the size of your Stuck\t"; cin >>size; cout<<pop(size);
getch(); }