To write a code which contains the function that shows the pattern below.
******************************
* *
* name *
* *
******************************
Write a code in C for the following pattern:
******************************
* *
* name *
* *
******************************
Make a function named ‘PrintName’ for displaying the name inside the aforementioned star pattern.
Call the function, PrintName, in the main function.
Want to see the full answer?
Check out a sample textbook solutionChapter 4 Solutions
Computer Science: A Structured Programming Approach Using C, Third Edition
- function myCompose(f,g){// TODO: return (f o g);// that is, a function that returns f(g(x)) when invoked on x.}arrow_forward‘Write a function get_names(), which prompts the user for a sequence of names, where each name can contain an arbitrary mix of uppercase and lowercaseletters and space characters, until the user enters "exit". The function should then return a list of capitalized names, whith no leading or trailing space, and with‘one space character separating adjacent words, Write a main() function to test the get_names() function. For example: Enter a name (exit to stop): bill clintonEnter a name (exit to stop): john tigER sMith Enter a name (exit to stop): mary beautiful Graceland Enter a name (exit to stop): exit [Bill Clinton’, “John Tiger Smith’, ‘Mary Beautiful Graceland’ ]arrow_forwardFor C++, How would I call or use a function that is passed by pointer or a reference? How would I use these in this example below? I understand how passing by value works, but when it comes to passing by references and pointers, that is when I get confused. #include <iostream> using namespace std; // passing by reference in this function void pass_ref(int &ref); // passing by pointer in this function void pass_ptr(int* ptr);arrow_forward
- Exercise 9-6: Pass by Reference and Pass by Address In this exercise, you use what you have learned about passing arguments by reference and by address to functions to answer Questions 1-2. 1. Given the following variable and function declarations, write the function call and the function's header a. double price 22.95, increase .10; void changePrice(doubl e&, double); b. double price 22.95, increase .10; void changePrice (double*, double); c. int age = 23; void changeAge(int&); d. int age 23; void changeAge (int*); 2. Given the following function headers and variable declarations, write a function call: a. custNames [] = {"Perez", "Smith", "Patel", "Shaw"}; balances [] = {34.00, 21.00, 45.50, 67.00); void cust (string name [], double bal []) b. int values [] = {1, 77, 89, 321, -2, 34}: void printSum (int nums [])arrow_forwardYou are tasked with helping write part of an exciting new word-guessing game, “Durdle”. The game is one in which a player attempts to guess a five-letter word in successive guesses. In this problem and the next one, we will build an implementation of this word-guessing game. First, to support this game, we will write a function named durdle_match(guess, target) that takes in two strings - a player’s guess, and the target word that the player is attempting to guess. Each of the given words is five letters long. This function should return a five-letter string consisting of the letters B, G, and Y that has a meaning associated with the guess as follows: B: This letter in the guess does not appear in the target string Y: This letter in the guess appears in the target string in another location G: This letter in the guess appears in the same location in the target stringarrow_forwardIn C++ without classes, given a time in 24-hour notation, write a function that adds 2 times, a function that substracts 2 times, and a function that displays the time in 12-hour notation.arrow_forward
- Write the definition for a function switch that receives as parameters first_name and last_name and prints them in reverse order. Write the call to the function from main, passing two names as parameters.arrow_forwardMc2. WRITE PYTHON FUNCTION THAT: You need to write the function which takes the index of the last point in the path sent, current, as well as the path, as arguments and returns the index of the next point to send. To write this function, remember the equations for the slope (m) of a line given two points on the line, and the offset (c) of a line give one point and the slope: y = mx +c. If you know the slope and offset, then whenever you are given a point (x1,y1) you can determine whether it lies on the line or not by evaluating r = y1-m*x1-c. This (y=mx+c) will be zero for a point on the line, and non-zero otherwise! The easiest way to see if you are on a straight line is to use the first two points to calculate m and c, then sum the value of r for the third, fourth, etc. until you reach a point where the sum of r exceeds some threshold value. That is, when the points have accumulated too much error from a straight line. You can use 0.1 as your default value of the threshold.…arrow_forwardGiven the code segment below, what should be the data type of the formal parameter in the function prototype of func(), given the call from main()? If the accessing is wrong, answer INVALID. void func( ______ );int main(){ double aData[6][4];func(aData[6]);return 0;}arrow_forward
- Write a C++ program for the following In this task, your job is to create a function Swapper() that takes three arguments num1,num2, and difference. The first argument should be passed by pointer, second argumentshould be passed by reference, and third argument should be passed by value. YourSwapper function should first swap the values of num1 and num2 with each other, andthen compute the difference of most significant digits of both numbers. You have to storethe difference result in difference variable. In the end, you need to display the values ofall three variables inside your Swapper method as well as in your main function.Note: You are not allowed to create any other variable or pointer inside your Swappermethod.arrow_forward1. Write a function which takes one parameter int num, and prints out a countdown timer with minutes and seconds separated by a colon (:). It should print out one line for each second elapsed and then pause one second before printing out the next line. A few things to note: - You can assume that calling the function usleep(1000000) makes the program pause for one second - It should count down from num minutes:zero seconds to zero minutes:zero seconds - Your function must have the following signature: void timer(int num) You do not need to demonstrate calling this function from main(). You don't need to format the output nicely; the below is acceptable output for calling this function when minutes is 10: 10:0 9:59 9:58 … 9:1 9:0 8:59 8:58 … 0:2 0:1 0:0arrow_forwardWrite a swap function, that swaps the values of two variables in main, but use pointers instead of reference parameters. WRITE IN C++arrow_forward
- C++ Programming: From Problem Analysis to Program...Computer ScienceISBN:9781337102087Author:D. S. MalikPublisher:Cengage Learning