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
Want to see the full answer?
Check out a sample textbook solutionChapter 9 Solutions
Problem Solving With C++ (Looseleaf) - With Access
Additional Engineering Textbook Solutions
Artificial Intelligence: A Modern Approach
Software Engineering (10th Edition)
Database Concepts (8th Edition)
Starting out with Visual C# (4th Edition)
Computer Systems: A Programmer's Perspective (3rd Edition)
Starting Out with Java: Early Objects (6th Edition)
- Write a program in c languageto find the sum of all non-prime numbers from m and n (including m and n also) using the concept of passing pointers to function. Pass addresses of m, n and sum integers from the main () function to the user defined function: calculate () [Function is not returning any value], and display the sum in the main () function.arrow_forwardLanguage: C Write the function convolve that will calculate the confolution of two functions f, g on [0, t] interval. The convolution is defined as (f ∗ g)(t) = Z t 0 f(τ )g(t − τ ) dτ for f, g : [0, ∞) → R. The argument function f and g should be passed by pointers. The integral should be approximated by the Riemman sum, i.e., Z b a f(x) dx = Xn i=1 f(xi) ∆x, where ∆x = b−a n and xi = a + i ∆x. Define the functions func1, func2 and func3, that return sin(x), cos(x) and x 3 respectively. Use these functions to calculate the convolution of f = sin(x), g = sin(x) f = sin(x), g = cos(x) f = sin(x), g = x 3 for t = 2π and n = 1000.arrow_forwardIn C++, If you had the double-pointer above and also had these variables: type x, * q; And had executed these statements: q = &x; p = &q; How would a function given p by value be able to change the contents of x?arrow_forward
- Write a C++ function named louder which accepts a pointer to a C-string as its argument. It should do 3 things: - change any period (.) in the C-string to an exclamation point (!) - change any lower case letter in the C-string to the corresponding upper case letter - return the number of characters which were changed You may assume that parameter str points to a valid, null-terminated C-string containing only alphabetic characters, spaces and periods. You do not need to demonstrate calling this function. Example: if str points to an array containing "Giants win." the function should change the array so that it contains "GIANTS WIN!", and should return 9. You must use this function signature: int louder(char *str)arrow_forwardWrite a C function that is given a pointer to memory, the number of bytes of memory the pointer points at, and two pointers to uint32_t. Your job is to treat the pointer as if it were a pointer to an array of uint32_t, find the min and max values of the array, and write the results to the locations pointed at by the uint32_t pointers. The number of bytes will be a positive multiple of 4. Do not worry about endianess in this problem. Note the tester has command line options -Wall -Wextra -Werror -fsanitize=address to help you catch errors.arrow_forwardWrite a C++ function that takes an array and its size as parameters, then calculates and returns the value, which is equal to max - min.arrow_forward
- Given a list of parent-child relationships represented as a list of structs, where each struct contains a string field for the name of the parent and a string field for the name of the child, write a function in C that takes in a child's name as a parameter and returns an array of strings containing the names of all the ancestors of that child. The function should also return the number of ancestors found through an integer pointer.arrow_forwardWrite a C++ program that asks for two lowercase characters. Pass the two entered characters, using pointers, to a function named capit(). The capit() function should capitalize the two letters and return the capitalized values to the calling function through its pointer arguments. The calling function should then display all four lettersarrow_forwardWrite a Function that takes a String as a parameter and returns the GC content (the proportion of bases that are either a G or a C) of that string.arrow_forward
- Write C++ program to take input of two numbers, pass them to a function which swap those numbers USING POINTER.arrow_forwardWrite a C program that uses a function to calculate Rt. The user will be prompted to enter R1, R2 & R3 which will be passed to the function as parameters, do not use global variables or pointers. The values have no specified range for them but if any of the 3 inputs are less than 0, the function should return 0. The main function should then display the calculated value of Rt with 2 decimal places or an appropriate error message. (Do not use printf or scanf inside the function ... all input/output should be in main) Use appropriate message to prompt the user to enter each value. Three resistors (R1, R2 and R3) are connected so that R1 & R2 are in parallel then in series with R3. Their equivalent resistance (Rt) is calculated using the following equation: Rt=(R1xR2/R1+R2)+R3arrow_forwardWrite a C++ program that swaps two values by passing pointers as arguments to function.arrow_forward
- C++ for Engineers and ScientistsComputer ScienceISBN:9781133187844Author:Bronson, Gary J.Publisher:Course Technology PtrC++ Programming: From Problem Analysis to Program...Computer ScienceISBN:9781337102087Author:D. S. MalikPublisher:Cengage Learning