Question

In C++ ------------------------------------------ All functions take no parameters as input and return nothing. Create a function...

In C++

------------------------------------------

All functions take no parameters as input and return nothing.

Create a function for each of the following:

  1. A function that reads all text up to a space character (' ') while outputting everything up to that space
  2. A function that reads two numbers (int) ending in a ';' and adds them together and outputs the result. Note: You only have to read the first two numbers.

Homework Answers

Answer #1

CODE IN C++:

#include <iostream>
using namespace std;
//method to take string from the user and displaying it
void display(){
string str;
cout << "Enter the text:";
cin>>str;
cout<<"Your text is:"<<str+" "<<endl;
}
//method to take two integers from the user and add them
void add(){
int a,b;
cout<<"Enter two numbers:";
cin>>a>>b;
cout<<"The sum of your numbers is:"<<a+b<<endl;
}
int main()
{
//calling the methods
display();
add();

return 0;
}
OUTPUT:

Know the answer?
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for?
Ask your own homework help question
Similar Questions
Arrays, loops, functions: Lotto Element Repeated Function Write a function that that takes as parameters an...
Arrays, loops, functions: Lotto Element Repeated Function Write a function that that takes as parameters an array of ints, an int value named element, and an int value named end. Return a bool based on whether the element appears in the array starting from index 0 and up to but not including the end index. Generate Random Array Write a function that takes as parameters an array of integers and another integer for the size of the array. Create a...
Write C++ code to: Create a function called “ReadFile” that: Accepts a filename as input Opens...
Write C++ code to: Create a function called “ReadFile” that: Accepts a filename as input Opens the file for reading Reads an integer from the file and returns it. Create a main function that Asks the user to input a file Passes that file to the “ReadFile” function Prints the returned integer to the screen Extra Credit: Set a default argument of “intfile.txt” for the “ReadFile” function Write an overloaded function of “ReadFile” that accepts two filenames and reads an...
Write a Python function which receives 3 lists as its input parameters and combines the lists...
Write a Python function which receives 3 lists as its input parameters and combines the lists and remove repeated numbers from the combined list and return the combined list. For instance, if the input is [1,2,3,4,2,3] and [3,4,6,7] and [-1,0,23,4] the result is [1,2,3,4,6,7,-1,0,23] - Note, the order the lists are combined together does not matter. Use main function.
For a C program hangman game: Create the function int setup_game [int setup_game ( Game *g,...
For a C program hangman game: Create the function int setup_game [int setup_game ( Game *g, char wordlist[][MAX_WORD_LENGTH], int numwords)] for a C program hangman game. (The existing code for other functions and the program is below, along with what the function needs to do) What int setup_game needs to do setup_game() does exactly what the name suggests. It sets up a new game of hangman. This means that it picks a random word from the supplied wordlist array and...
Be sure to create the algorithms (pseudocode or flowcharts) for all 4 functions plus the main...
Be sure to create the algorithms (pseudocode or flowcharts) for all 4 functions plus the main program. Create a very simple larger( ) function that takes 2 positive numbers as parameters and returns the larger value of the two numbers.    Use your larger function to help create the following functions -- reuse your function code. Create a simple larger3( ) function that takes 3 positive numbers as parameters and returns the largest value of the three numbers.   Create a simple...
Part 1 Write a program that reads a line of input and display the characters between...
Part 1 Write a program that reads a line of input and display the characters between the first two '*' characters. If no two '*' occur, the program should display a message about not finding two * characters. For example, if the user enters: 1abc*D2Efg_#!*345Higkl*mn+op*qr the program should display the following: D2Efg_#! 1) Name your program stars.c. 2) Assume input is no more than 1000 characters. 3) String library functions are NOT allowed in this program. 4) To read a...
Using the following code perform ALL of the tasks below in C++: ------------------------------------------------------------------------------------------------------------------------------------------- Implementation: Overload input...
Using the following code perform ALL of the tasks below in C++: ------------------------------------------------------------------------------------------------------------------------------------------- Implementation: Overload input operator>> a bigint in the following manner: Read in any number of digits [0-9] until a semi colon ";" is encountered. The number may span over multiple lines. You can assume the input is valid. Overload the operator+ so that it adds two bigint together. Overload the subscript operator[]. It should return the i-th digit, where i is the 10^i position. So the first...
FOR PYTHON Rewrite your pay computation with time-and-a-half for overtime and create a function called compute_pay...
FOR PYTHON Rewrite your pay computation with time-and-a-half for overtime and create a function called compute_pay which takes two parameters (hours and rate). Enter Hours: 45 Enter Rate: 10 Pay: 475.0 YOU WILL NEED THREE FUNCTIONS: the_hours, the_rate = get_input() the_pay = compute_pay(the_hours, the_rate) print_output(the_pay) Call the functions and passing the arguments in the "main" function. Example: def main(): the_hours, the_rate = get_input() the_pay = compute_pay(the_hours, the_rate) print_output(the_pay) main() ----- Testing the outputs of your code: 1 for the valid...
c++ 19.36 LAB: Output values below an amount - functions Write a program that first gets...
c++ 19.36 LAB: Output values below an amount - functions Write a program that first gets a list of integers from input. The input begins with an integer indicating the number of integers that follow. Then, get the last value from the input, and output all integers less than or equal to that value. Ex: If the input is: 5 50 60 140 200 75 100 the output is: 50 60 75 The 5 indicates that there are five integers...
functions exist in a variety of settings outside of the commonly known examples of plugging in...
functions exist in a variety of settings outside of the commonly known examples of plugging in a number and receiving a number as an output. For example, if using the letters on a keyboard and monitor for a computer (assuming everything is connected properly), pushing the B key on the keyboard will result in the letter b appearing on the monitor. With differing keystrokes resulting in a different letter appearing across the screen, the relation connecting the keystrokes of the...
ADVERTISEMENT
Need Online Homework Help?

Get Answers For Free
Most questions answered within 1 hours.

Ask a Question
ADVERTISEMENT