Answered step by step
Verified Expert Solution
Question
1 Approved Answer
Write a function that accepts a character array, a zero-based start position and a length. It should return a character array containing containing length characters
- Write a function that accepts a character array, a zero-based start position and a length. It should return a character array containing containing lengthcharacters starting with the startcharacter of the input array. The function should do error checking on the start position and the length and return null if the either value is not legal. The function signature is: char[ ] f(char[ ] a, int start, int len)
Examples
if input parameters are | return |
{a, b, c}, 0, 4 | null |
{a, b, c}, 0, 3 | {a, b, c} |
{a, b, c}, 0, 2 | {a, b} |
{a, b, c}, 0, 1 | {a} |
{a, b, c}, 1, 3 | null |
{a, b, c}, 1, 2 | {b, c} |
{a, b, c}, 1, 1 | {b} |
{a, b, c}, 2, 2 | null |
{a, b, c}, 2, 1 | {c} |
{a, b, c}, 3, 1 | null |
{a, b, c}, 1, 0 | {} |
{a, b, c}, -1, 2 | null |
{a, b, c}, -1, -2 | null |
{}, 0, 1 | null |
by java
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started