Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Lab 8 (this is to be turned in) Palindrome is a string that is the same as backwards or forwards otto ababa noon ababbbbaba In

Lab 8

(this is to be turned in)

Palindrome is a string that is the same as backwards or forwards

otto

ababa

noon

ababbbbaba

In this lab we will work with strings (so we will be using character arrays).

1.

Write a program that reads two strings

str1

and

str

2

from the

keyboard

2.

Print both strings

3.

Write a function

computeLength

and call this function in main to compute

the

length of the string

str1

and

str2

.

4.

if the string

str1

is of length 1 the program will terminate

5.

if the string

str

2

is of length 0 the program will ter

minate

Next

A

prefix

of a st

ring is a nonempty string that is an initial segment

Example

moondog

has prefixes of moo, m, moon, mo, moond,....

6.

Write a function

is

Prefix (str1, str2)

that returns 1 if the string

str

2

is a prefix of

str1 substring of

str1

then

is

Prefix

should return a ONE , if not retur

n a ZERO.

See class discussion for the definition

7.

Call this function with str1 and str2 in main and output your result

8.

Now write a function

isPalindrome(str)

that returns a 1 if

str

is a palindrome

and 0 otherwise. To get full credit use i

sPrefix

i n your function

9.

Call your function

isPalindrome(str

1)

10.

O utput the correct conclusion either

PALINDROME

or

NOT PALINDROME

You are

NOT

to use any standard library functions except for I/O functions

.

You will determine the above and output each in a form

atted manner.

Here is a potential list of functions you may want to declare

int computeLength(char *str

);

int is

Reverse

Prefix(char *str1, char *str2);

int isPalindrome

(char *str

);

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Relational Database And Transact SQL

Authors: Lucy Scott

1st Edition

1974679985, 978-1974679980

More Books

Students also viewed these Databases questions

Question

Connect with your audience

Answered: 1 week ago