Database System Concepts
Database System Concepts
7th Edition
ISBN: 9780078022159
Author: Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher: McGraw-Hill Education
Bartleby Related Questions Icon

Related questions

Question
COMP.1020 Computing II
UMASS - Lowell
#include <stdio.h>
char *reverse(char *word);
Write a function called reverse that accepts a c-string as an argument and reverses that argument in place
(meaning you should not create another array to store the result) returning the address of the first element
of the c-string as a character pointer when you are finished. For example, if your c-string contains the string
"Happy Birthday!" then after a call to the function your string would contain "lyadhtriB yppaH". For this
assignment you may not use the string.h library or any other library except stdio.h. You may assume the
following main program which would print the string forward, backward, and then forward again twice:
int main(int arge, char* argy [])
{
HW1 Spring 2023
char word [] "Happy Birthday!";
printf("%s\n", word);
reverse (word);
printf("%s\n", word);
printf("%s\n", reverse (word));
printf("%s\n", word);
return 0;
}
Place the code for your function in a file called reverse.c and submit only this file to me on blackboard. The
file should contain the definition for your function reverse and nothing else. I will use my own header file and
main program to test your code. Please keep in mind that this function should work for any valid C style
string and the fact that the above program works for "Happy Birthday!" is just one example. You should
try it with strings of even and odd lengths as well as very short strings.
expand button
Transcribed Image Text:COMP.1020 Computing II UMASS - Lowell #include <stdio.h> char *reverse(char *word); Write a function called reverse that accepts a c-string as an argument and reverses that argument in place (meaning you should not create another array to store the result) returning the address of the first element of the c-string as a character pointer when you are finished. For example, if your c-string contains the string "Happy Birthday!" then after a call to the function your string would contain "lyadhtriB yppaH". For this assignment you may not use the string.h library or any other library except stdio.h. You may assume the following main program which would print the string forward, backward, and then forward again twice: int main(int arge, char* argy []) { HW1 Spring 2023 char word [] "Happy Birthday!"; printf("%s\n", word); reverse (word); printf("%s\n", word); printf("%s\n", reverse (word)); printf("%s\n", word); return 0; } Place the code for your function in a file called reverse.c and submit only this file to me on blackboard. The file should contain the definition for your function reverse and nothing else. I will use my own header file and main program to test your code. Please keep in mind that this function should work for any valid C style string and the fact that the above program works for "Happy Birthday!" is just one example. You should try it with strings of even and odd lengths as well as very short strings.
Expert Solution
Check Mark
Knowledge Booster
Background pattern image
Computer Science
Learn more about
Need a deep-dive on the concept behind this application? Look no further. Learn more about this topic, computer-science and related others by exploring similar questions and additional content below.
Similar questions
SEE MORE QUESTIONS
Recommended textbooks for you
Text book image
Database System Concepts
Computer Science
ISBN:9780078022159
Author:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:McGraw-Hill Education
Text book image
Starting Out with Python (4th Edition)
Computer Science
ISBN:9780134444321
Author:Tony Gaddis
Publisher:PEARSON
Text book image
Digital Fundamentals (11th Edition)
Computer Science
ISBN:9780132737968
Author:Thomas L. Floyd
Publisher:PEARSON
Text book image
C How to Program (8th Edition)
Computer Science
ISBN:9780133976892
Author:Paul J. Deitel, Harvey Deitel
Publisher:PEARSON
Text book image
Database Systems: Design, Implementation, & Manag...
Computer Science
ISBN:9781337627900
Author:Carlos Coronel, Steven Morris
Publisher:Cengage Learning
Text book image
Programmable Logic Controllers
Computer Science
ISBN:9780073373843
Author:Frank D. Petruzella
Publisher:McGraw-Hill Education