You are on page 1of 1

Object Oriented Programming Practical

Exercise 5

Exercise 5

Reversing a Given String

Objective: This exercise enables you to understand the concept of character arrays and string functions in Java. Procedure: This program prints the original string and the reversed string on the console. Algorithm: The algorithm for the program is given below: /* A string can be thought of as a single dimensional character array. */ Step 1: Open a new text document on your desktop. Step 2: Write the following code in the main function: 2.1: Declare two character arrays, say A and B. 2.2: Fill in the first array, say A with a set of characters. 2.3: Write the code for reversing the contents of A and store it character by character in array B. Step 3: Print the arrays A and B on the console. Sample Output: Original String: A = abcde Reverse String: B = edcba

Sikkim Manipal University

Page No.: 6

You might also like