Question

In: Mechanical Engineering

Write a function that takes a C string as an input parameter and reverses the string.

in c++

Write a function that takes a C string as an input parameter and reverses the string. The function should use two pointers, front and rear. The front pointer should initially reference the first character in the string, and the rear pointer should initially reference the last character in the string. Reverse the string by swapping the characters referenced by front and rear, then increment front to point to the next character and decrement rear to point to the preceding character, and so on, until the entire string is reversed. Write a main program to test your function on various strings of both even and odd length.

Solutions

Expert Solution


Related Solutions

in c++ Write a function that takes a C string as an input parameter and reverses...
in c++ Write a function that takes a C string as an input parameter and reverses the string. The function should use two pointers, front and rear. The front pointer should initially reference the first character in the string, and the rear pointer should initially reference the last character in the string. Reverse the string by swapping the characters referenced by front and rear, then increment front to point to the next character and decrement rear to point to the...
Write a function named "characters" that takes a string as a parameter and returns the number...
Write a function named "characters" that takes a string as a parameter and returns the number of characters in the input string
C++ Please Define a function named "isAscending" that accepts a string as an input parameter and...
C++ Please Define a function named "isAscending" that accepts a string as an input parameter and returns "true" if all the characters included in the string are ordered in ascending order of their ASCII codes or the input string is a null string, and returns "false" otherwise. For example, if the string "ABXab" is passed to the function, it returns "true" because the ASCII code of 'B' is greater than 'A', 'X' is greater than 'B', 'a' is greater than...
Write a function called fnReadInParameters() that takes as parameter(s): • a string indicating the name of...
Write a function called fnReadInParameters() that takes as parameter(s): • a string indicating the name of the parameter le This function should return a dictionary that stores all of the parameter le data of the SIR model in a format that we will describe further below.
C++ Write a program that takes a string and integer as input, and outputs a sentence...
C++ Write a program that takes a string and integer as input, and outputs a sentence using those items as below. The program repeats until the input string is "quit". If the input is: apples 5 shoes 2 quit 0 the output is: Eating 5 apples a day keeps your doctor away. Eating 2 shoes a day keeps your doctor away.
Write A function with an input parameter which is a string arithmetic statement which contains only...
Write A function with an input parameter which is a string arithmetic statement which contains only alphabet variables and binary operations including +, -, *, / and % and checks whether the statement is a valid arithmetic statement or not. If the statement is valid, the function returns true, otherwise returns false. • The statement might contain parenthesis as well. For instance: • a+b*a+c/c%y • (a+b)*(a/d-(a/b)) • You can make this assumption that the variable names contain only one alphabet...
Using SQL, write a table-valued function that: -- takes a space delimited string as input (Input...
Using SQL, write a table-valued function that: -- takes a space delimited string as input (Input string will be a sentance ex: "The cat is on the chair and the bear is on the chair") -- returns a table (word varchar(max), count int) (Output is a table that shows how many times each word appeared in the sentance) Where each space-delimited “word” in the string appears in the table along with the number of times it appeared in the input...
Matlab Create/write a function that takes an input of x and y data, and a string...
Matlab Create/write a function that takes an input of x and y data, and a string (either linear? or quadratic), sets up a linear system of equations (Ax = b), and solves and plots the model.
In this C program, the function reverseStr reverses the nth word in a string. If n...
In this C program, the function reverseStr reverses the nth word in a string. If n is larger than the number of words in the string then the function returns 0, else return the function modifies the string and returns 1. Task: write the reverseStr function that follow the requirements below: 1. consistent with the prototype and code below 2. original string must be changed 3. DON'T use functions in string.h Tips: 1. string input to this function is non-empty,...
C++ Write a function called linearSearch that takes an array as a parameter and search for...
C++ Write a function called linearSearch that takes an array as a parameter and search for a specific value inside this parameter. The function returns the frequency of a specific value in the array. In the main function: 1. Define an array called salaries of length 5. 2. Initialize the array by asking the user to input the values of its elements. 3. Define a variable called key and ask the user to enter a value for this variable. 4....
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT