OUTPUT 2012

The following function witty() is a part of some class. What will be the output of the function witty() when the value of n is SCIENCE and the value of p is 5. Show the dry run/working.

void witty ( String n, int p)
    {
        if (p<0)
        System.out.println("  ");
        else
        {
            System.out.println( n.charAt(p) + ".");
            witty(n,p-1);
            System.out.print(n.charAt(p));
        }
    }

witty(“SCIENCE”,5)          C.

    witty(“SCIENCE”,4)         N.

      witty(“SCIENCE”,3)         E.

         witty(“SCIENCE”,2)        I.

           witty(“SCIENCE”,1)          C.

             witty(“SCIENCE”,0)         S.

                witty(“SCIENCE”,-1)   

                                                            SCIENCE

This entry was posted in Output. Bookmark the permalink.

Leave a Reply

Your email address will not be published. Required fields are marked *