Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

C program (not C++) Write a function in C called reverse string that takes in any size string and returns the reverse of the string.

C program (not C++)

Write a function in C called reverse string that takes in any size string and returns the reverse of the string. the code must Use pop and push functions as described below. (the program must take user input)

-declare a stack variable ex: char stack[s]

-declare a string variable called reversed within the function. this should be returned by the function and printed.

-if a string is entered, push all the individual characters into the stack. the last character in the string is pushed last

- pop all the characters from the stack to the reversed string function, until the stack is empty. the last character pushed is popped first.

- return and print the reverse string.

EX.

input: cat and dog

output: god dna tac

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

Conceptual Database Design An Entity Relationship Approach

Authors: Carol Batini, Stefano Ceri, Shamkant B. Navathe

1st Edition

0805302441, 978-0805302448

Students also viewed these Databases questions