1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.

. Know how to do these, to trace functions like these and to debug functions like the

Discussion in 'C++' started by fmmctg0001, Nov 3, 2012.

  1. fmmctg0001

    fmmctg0001 New Member

    Joined:
    Sep 6, 2012
    Messages:
    2
    Likes Received:
    0
    Trophy Points:
    0
    please somebody can help to debugging this

    Code:
    // recursive power , compute xn
    int exp(int x, int n){
    if(n==_______)
    return _________;
    return ____________*exp(_________);
    }
    void main(){
    int a,b;
    cin >>a>>b;
    cout<<endl<<exp(a,b)<<endl;
    }
    // recursive print of a string
    void print(char* s){
    if(*s==____________)
    return;
    cout<<*s;
    print(______________);
    }
    void main(){
    char a[6]="hello";
    print(a);
    }
    // recursive reverse print of a string
    void rev_print(char* s){
    if(*s==____________)
    return;
    ____________________________;
    ___________________________;
    }
    void main(){
    char a[100];
    cin>>a;
    rev_print(a);
    }6
    // recursive reverse print of an integer
    void rev_print(int n){
    if(n/10==0){
    cout<<n%10;
    return;
    }
    cout<<__________________________;
    rev_print(___________________); 
    }
    void main(){
    int a;
    cin>>a;
    rev_print(a);
    }
    // recursive print of an integer
    void print(int n){
    if(n/10==0){
    cout<<n%10;
    return;
    }
    print(_______________);
    cout<<___________________;
    }
    void main(){
    int a;
    cin>>a;
    print(a);
    }
     
    Last edited by a moderator: Nov 4, 2012

Share This Page