Concept explainers
Study the following
// The Works of Wolfgang
#include <iostream>
using namespace std;
int main()
{
cout ≪ “The works of Wolfgang\ni nclude the following”;
cout ≪ “\nThe Turkish March” ≪ endl;
cout ≪ “and Symphony No. 40 ” ;
cout ≪ “in G minor.” ≪ endl ;
return 0;
}
Learn your wayIncludes step-by-step video
Chapter 2 Solutions
Starting Out with C++ from Control Structures through Objects Brief, Student Value Edition (8th Edition)
Additional Engineering Textbook Solutions
Starting Out with Python (4th Edition)
Objects First with Java: A Practical Introduction Using BlueJ (6th Edition)
Modern Database Management (12th Edition)
Starting Out with Java: Early Objects (6th Edition)
Starting out with Visual C# (4th Edition)
Java: An Introduction to Problem Solving and Programming (8th Edition)
- 17. Redo Programming Exercise 16 so that the user can also input the cost of producing one liter of milk and the profit on each carton of milk.arrow_forwardQuestion 1 is already done need help with the others though This is the C code I have so far #include <stdio.h> #include <stdlib.h> struct employees { char name[20]; int ssn[9]; int yearBorn, salary; }; struct employees **emps = new employees()[10]; //Added new statement ---- bartleby // function to read the employee data from the user void readEmployee(struct employees *emp) { printf("Enter name: "); gets(emp->name); printf("Enter ssn: "); for(int i =0; i <9; i++) scanf("%d", &emp->ssn[i]); printf("Enter birth year: "); scanf("%d", &emp->yearBorn); printf("Enter salary: "); scanf("%d", &emp->salary); } // function to create a pointer of employee type struct employees *createEmployee() { // creating the pointer struct employees *emp = malloc(sizeof(struct employees)); // function to read the data readEmployee(emp); // returning the data return emp; } // function to…arrow_forwardStudy the block of codes below: int main(){ char s[] = "Get organized! Learn C!";} What would the output be if the following code is added at the end of the main() function? printf("%s", &s[2]);arrow_forward
- Question 4 Write a C++ program that evaluates Ly=b and then Ux=y. L and U are the upper and lower triangular matrices of a square matrix A. b is a set of randomly generated numbers. Solve the equations to get the solution x. Full explain this question and text typing work only thanksarrow_forwardConsider the following obfuscated and confusing program code below. #include <iostream> using namespace std; int fib(int); int main() { cout << "Enter an index for the Fibonacci number: "; int index; cin >> index; cout << "Fibonacci number at index " << index << " is " << fib(index) << endl; return 0; } int fib(int index) { if (index == 0) return 0; else if (index == 1) return 1; else return fib(index - 1) + fib(index - 2); } Create a C++ Builder Console Project and copy/paste the above code into the .cpp file of the project. Run the project... it should run fine. Now, REFORMAT the code to demonstrate you know Software Engineering principles in making code readable and understandable. FOLLOW the exmples that are given in the textbook and the learning activities. ADD COMMENTS to document what the program/code does. You will be expected to format your code throughout this course using proper indentations and placement of curly braces. STUDY…arrow_forwardQ13/ Write a program in c++ that asks the user to input two numbers. If the first number entered is greater than the second number, the program should print the message: "The first number is greater." Otherwise, it should print the message: "The first number is smaller." .By using functionsarrow_forward
- 6.10 LAB: Driving costs - functions Driving is expensive. Write a program with a car's miles/gallon and gas dollars/gallon (both floats) as input, and output the gas cost for 10 miles, 50 miles, and 400 miles. Output each floating-point value with two digits after the decimal point, which can be achieved as follows:print('%0.2f' % your_value) Ex: If the input is: 20.0 3.1599 the output is: 1.58 7.90 63.20 Your program must define and call the following driving_cost() function. Given input parameters driven_miles, miles_per_gallon, and dollars_per_gallon, the function returns the dollar cost to drive those miles. Ex: If the function is called with: 50 20.0 3.1599 the function returns: 7.89975 def driving_cost(driven_miles, miles_per_gallon, dollars_per_gallon) Your program should call the function three times to determine the gas cost for 10 miles, 50 miles, and 400 miles. Note: This is a lab from a previous chapter that now requires the use of a function.arrow_forward6.20 LAB: Driving costs - functions Driving is expensive. Write a program with a car's miles/gallon and gas dollars/gallon (both floats) as input, and output the gas cost for 10 miles, 50 miles, and 400 miles. Output each floating-point value with two digits after the decimal point, which can be achieved as follows:print('{:.2f}'.format(your_value)) Ex: If the input is: 20.0 3.1599 the output is: 1.58 7.90 63.20 Your program must define and call the following driving_cost() function. Given input parameters driven_miles, miles_per_gallon, and dollars_per_gallon, the function returns the dollar cost to drive those miles. Ex: If the function is called with: 50 20.0 3.1599 the function returns: 7.89975 def driving_cost(driven_miles, miles_per_gallon, dollars_per_gallon) Your program should call the function three times to determine the gas cost for 10 miles, 50 miles, and 400 miles. I need help with this. Use Python, please.arrow_forwardAnnotate each line of the following code including what each built-in function does. #include <iostream> #include <string> using namespace std; int main() { string woo = “”; string s1 = "who's woods these are I think I know "; s1 += " his house in in the village low."; cout << s1 << " " << s1.length() << endl << endl; cout << s1.at(10) << endl; cout << s1.substr(10, 6); s1.insert(10, "hi there"); cout << s1 << endl; s1.erase(5, 6); cout << s1 << endl; woo = s1.substr(0, s1.find(" ")); s1.clear(); cout << s1 << endl; cout << s1.empty() << endl; cout << woo << endl;…arrow_forward
- Hello. I'm working on a triangle and house in C++. I'm a bit confused on how to continue, especially with adding void and arguments. What's Needed: functions in C++. declare function prototypes in C++. use void functions in C++. pass information into functions using arguments. Program Requirement: main should prompt the user for one character and two integer values before drawing a rectangle and triangle by calling the functions appropriately. draw_rectangle is a void function that accepts 3 arguments (the character symbol, integer width, and integer height). It should repeatedly call the draw_bar function to draw the rectangle shape. draw_bar should accept 2 arguments (the character symbol and an integer value width). It will use a loop to draw a horizontal bar of the character. draw_triangle should accept 2 arguments (the symbol and integer height). It should also repeatedly call the draw_bar function to draw the triangle of symbols to the screen as seen in the sample runs.…arrow_forwardPLEASE SOLVE THIS IN C++ CODE ONLY! PLEASE READ AND DO THE PROGRAM WITH ACCORDING TO THE CONDITIONS GIVEN. PLEASE ALSO WRITE THE USE OR FUNCTIONS OF EACH CODE USED BY INSERTING ITS USE EVERY LINE USING "//" A palindrome is a string that reads the same from front to back as it does from back to front, e.g., "racecar", "radar", "21012". Write a program that will identify whether a given line of input is a palindrome or not. Your program must also be able to determine the following sample inputs as palindromes, aside from identifying one-word inputs: Able was I 'ere I saw Elba. Madam, I'm Adam. A man, a plan, a canal, Panama. These samples require that your program must ignore spaces and punctuations, and consider uppercase and lowercase letters to be the same. Include necessary functions in your program to process the input. You can also use existing functions from the string library.arrow_forwardIn C++, please revise/fix the program below according to the instructions and all the criteria. I believe the problem is in int main(). Thank you. Instruction Write and test a function that returns a copy of its string parameter with no repeated characters. The functions ignore case when they compare letters. The functions return strings whose letters are upper case. Write 2 versions of the function: string remDups(const string& original); void remDups(const string& original, string& nodups); Suppose the original string is “Myrtle has big feet” The function returns MYRTLE HASBIGF Test the functions thoroughly. Criteria compile, run, test the test program compiles, runs, and calls both versions of the function without crashingthe test program tests the functions thoroughly function parameters and returns one function has one constant string reference parameter and returns a stringone function has one constant string reference parameter, one string reference parameter and…arrow_forward
- C++ Programming: From Problem Analysis to Program...Computer ScienceISBN:9781337102087Author:D. S. MalikPublisher:Cengage Learning