1) create food.txt with the following contents turkey 20.80 pie 7.4 stuffing 2.68 2) read the values from file.txt in a function using references parameters [Note: You must write a function and you must use reference parameters] 3) Print the cost for each item and total cost [Note: Your costs should be in the following format dollar sign dollars sents and show 2 decimal points]
Q: Levenshtein distance is the minimum number of editing operations (insertions, deletions, or…
A: The Levenshtein distance (a.k.a edit distance) is a measure of similarity between two strings. It is…
Q: SOB 35 – (Block 2 – material covered in Week 13) Write a function that takes a number n as input,…
A: As per guidelines we are supposed to answer only one question. Kindly repost other questions as a…
Q: Q.1) Mark the following statements as true or false and correct the second part if false: 1. The…
A: Array is a collection of similar datatypes. The types of array are Single dimensional…
Q: ython Q1) Write a function get_new_grades, such that given a list of grades as an input…
A: According to the Question below the solution: As per our guidelines we are supposed to answer?️ only…
Q: 8: PGandE.cpp) Consider a gas and electric bill that sets two levels of use as follows: Electric 558…
A: #include <iostream>#include <fstream>using namespace std; double calculation(string…
Q: Write a C++ function with the following signature: int sumArray(int arr[], int n) that returns the…
A: Here is the c++ code:
Q: function myCompose(f,g){// TODO: return (f o g);// that is, a function that returns f(g(x))…
A:
Q: Question 40. Consider the following code chunk: import random x = 0 while (x < 4): x = random.choice…
A: Given:
Q: rps (Exercise 5.26 from the textbook) Write a function rps that returns the result of a game of…
A: The solution for the above given question is given below:
Q: Memory is allocated for a function when the function is * declared defined O called O returned…
A: As per our policy, "Since you have asked multiple questions, we will solve the first question for…
Q: Write a function double power(double x, int n) that will compute xn
A: This question comes from Programming Language which is a paper of Computer Science. Let's discuss it…
Q: QUESTION 3 Suppose the following declarations appear in the mainfunction of a C++ program: string…
A: ANS -- 3:- Correct option -- 1. void approvedFunds(string courseP, string nameP, string & dateP,…
Q: Given the following comments and function declarations, write matching function definitions.…
A: Main concept used here. Pointer:- A variable which points to address. To access pointer variable ,…
Q: For this c++ hw 1) Make a function that reads in 2 integers from the user. (call it Get2Ints) 2)…
A: Below is the C++ program with explanation: - Explanation: - Importing the essential headers and the…
Q: evaluate the following function
A: % given vector = randn (35,1) %given function as inline y=@(x) sin (x) *2*x* cos(x) %plot for…
Q: 4. Write a function named 'sum_fib3' which will take input int n and return the sum of the (n-1)th,…
A: #include <stdio.h>//the function will take n value as parameter//and return the sum of…
Q: Write a function called myFind which accepts a 2 strings as parameters (tmp and strToFind) and…
A: Code: def main(): print(myFind("welocmetobartleby","bartle")) #myFind method will take the…
Q: 10.) Write a function, is_prime, which takes a single integer argument and returns prime number and…
A: Given: To write a python function is_prime which returns true when a argument is prime otherwise…
Q: 1-Using C++ predefined functions, write each of the following as C++ expression. + 2b…
A: As per our guidelines, we are not supposed to answer more than three subparts of a question and…
Q: 17. Write a sub-function “conversion()" based on the program below to convert the time to unit…
A: code snippet:
Q: 4. Write a function named 'sum_fib3' which will take input int n and return the sum of the (n-1)th,…
A: According to the question, we have to write a c program to find the output according to given…
Q: Consider the following code chunk: import random x=0 while(x < 4): x = random.choice([1, 2, 3])…
A: Python is an interpreted and object oriented programming language. "random" is a module in python…
Q: : dengue and malaria. Write a complete C++ program to accomplish the following tasks: Task 1:…
A: Task1 and task2 are implemented as follows: //task1 int year[10]; int dengue[10];…
Q: 4. Write a function that receives an x vector, a minimum value, and a maximum value. If the minimum…
A: The function which receives and x vector, a minimum value, and a maximum value is been made below,…
Q: 13. Let the function fun be defined as int fun (int*k) { *k +- 4; return 3 * (*k) - 1; Suppose fun…
A: According to the Question below the Solution:
Q: 11. Give definition for overloading functions, provide some examples. 12. A program contains the…
A: Solution
Q: Exercise 3.5 Write a function reprRealImag (x) that will represent the complex sequence x as two…
A: Algorithm: 1. Create a list of complex numbers 2. Create a list of the real and imaginary parts of…
Q: 4. Write a function named 'sum_fib3' which will take input int n and return the sum of the (n-1)th,…
A: As given, I need to write a C program having function called 'sum_fib3' that returns the sum of…
Q: 3. Write a function called e2_age_range that computes how many people fall within a certain age…
A: Input : Vector A, max_age , min_age Output : Elements of vector in between min_age and max_age.
Q: EXERCISE 15 Write a function Your first name_Last name_Ex15 with three variables x, y, and z as…
A: ANSWER:-
Q: Create a function that takes two dates and returns the number of days between the first and second…
A: In this problem, we need to provide the solution in java Script programming language. Input -…
Q: Consider the following code fragment. Assume this code is running within a function with appropriate…
A:
Q: Describe the input, process and output of the following function. void reserveroom(vector&…
A: Input: It accepts a vector of HotelRoom type as input argument, the number of the user's…
Q: 5.2 Write a function in Javascript to take input a matrix as a parameter and returns whether the…
A: As per the given question we need to write a function : Input parameter : A matrix To check if the…
Q: Assume a function F1 is defined with the heading: void F1(int a, double &b, double t]); Assume the…
A: Lets see the solution.
Q: 2. Write title lines for the following functions. Do not supply the blocks for the functions. (a) A…
A: Title line for (a): Answer: int sumDigits() Title line for (b): Answer: bool isSmall(double d)
Q: 3. Write a user-defined function inputData to take 15 students' names and total marks from user…
A: The code is written below in c language- #include<stdio.h> // defining a structure to…
Q: 9. Write a function that receives marks received by a student in 7 subjects and returns the avera…
A: Program Approach: Include necessary header files to get the standard I/O. Define a function to…
Q: 22. Create a C++ function that takes two integers p and q as the parameters and then returns true in…
A: C++ Code: #include <iostream>using namespace std; bool fun(int p, int q){ if (p == 10) return…
Q: 39. 6.49 (Pass-by-Value vs. Pass-by-Reference) Write a complete C++ program with the two alternate…
A: #include <iostream>using namespace std; // Pass by valueint tripleByValue(int count){ count…
Q: 4- The function sum_n_avg computes the sum and the average of three input arguments and relays its…
A: Given function is double one, two, three, sum_of_3, avg_of_3; printf("Enter three numbers> ");…
Q: C Programming-Plz fix this code We can return multiple values from functions using pointers. Let's…
A: Required: C Programming-Plz fix this code We can return multiple values from functions using…
Q: 公 * 00 9. Write the has_same_words_count user defined function, call it, and print out the results:…
A: 1. define the two strings str1 and str2 2. now call the function has_same_words_count(str1, str2) 3.…
Q: Implement the following functions. Each function deals with null terminated C-Style strings. You can…
A: Here, I have to provide a solution to the above question.
Q: 8: PGandE.cpp) Consider a gas and electric bill that sets two levels of use as follows: Gas 10.1…
A: The main object of the program is to read the starting reading gas consumption and ending reading…
Q: 1-The function sum_n_avg computes the sum and the average of three input arguments and relays its…
A: Since you have asked multiple questions, we will solve the first question for you. If you want any…
Q: Driving cost - functions. Write a function DrivingCost with parameters drivenMiles, milesPerGallon,…
A: According to the question All items are of type double. ... Output each floating-point value with…
Q: Consider the function definition: void GetNums(int howMany, float& alpha, float& beta)…
A: When GetNums function is calledWhen the GetNums function is called, then at first the run time…
C++ must attach ouput and code screen shot and editable code
also do add comments
answer correctly else downvote
Trending now
This is a popular solution!
Step by step
Solved in 3 steps with 4 images
- Create a new file in c++ and save it as lab11_XYZ.cpp (replace XYZ with your initials). Create ANOTHER new file (in C++) and save it as swap_XYZ.h (replace XYZ with your initials). Use the swap_XYZ.h header file to define a set of functions for swapping two items of the same type. Given the following prototypes, define (overloaded) swap functions void swap(int&, int&); //swap two integers void swap(double&, double&); //swap two doubles void swap(float&, float&); //swap two floats void swap(char&, char&); //swap two characters void swap(string&, string&); //swap two strings The header file should contain the following: header comments (similar to normal program header comments) function prototypes (provided above) function definitions (for you to do...) In general, a swap works like this: void swap(type first&, type second&){ type temp = first; first = second; second = temp; } Once your header file (H file) is complete, make…c++ Please Dont use Chegg for this problem 15.7 In-Lab Activity 7: Shapes (I/O operator overloading) In this program, you must implement I/O operator overloading (<< and >>) to match a shape's functionality. You must modify the following files: Triangle.h Implement the declaration for the overloaded I/O operator functions. Triangle.cpp Implement the calculateArea() function to find the area of the triangle. Implement the definitions for the overloaded I/O operator functions. The input function will take in two variables: The base and height (cin >> base >> height) Call the object's calculateArea() function after inputting the variables. The output function will send the following to the output stream (for base = 10 and height = 20): Triangle Object: Base: 10 Height: 20 Area is: 100 Square.h Implement the declaration for the overloaded I/O operator functions. Square.cpp Implement the calculateArea() function to find the area of the square. Implement…Write a void function that will merge the contents of two text files containing the chemical elements into a single binary file. The function's parameters will be three file pointers; each text file will contain an integer atomic number followed by the element name, chemical symbol and atomic weight. Here are two sample lines: 11 Sodium Na 22.9920 Calcium Ca 40.08 The function can assume that one file does not two copies of the same elements and that the binary output file should have the same property. IN C PLEASE
- Use C++ I need three files, one main.cpp file, one rational.cpp file and one rational.h file. I'll put the code for the main.cpp file and rational.h file below. No need to change them I just need the rational.cpp file. Modify the code to have operator overloading functions with the following operators.==, <, <=, >, >=, +, -, *, /Use the Rational interface and main code in the next page. main.cpp: #include <iostream>#include "rational.h"int main(){ Rational r1, r2; char answer = 'y'; while (answer == 'y') { cout << "Enter the first fraction (e.g. 3/4) : "; cin >> r1; cout << "Enter the second fraction (e.g. 3/4) : "; cin >> r2; cout << "r1 : " << r1 << endl; cout << "r2 : " << r2 << endl << endl; cout << "r1 + r2 = " << r1 + r2 << endl; cout << "r1 - r2 = " << r1 - r2 << endl; cout << "r1 * r2 = "…In this final submission, you will build on checkpoint B to load the database and DNA sequence from files. There will be two databases and several sequences that will be available for download below. Example of the database is the file small.txt: name,AGATC,AATG,TATC Alice,2,8,3 Bob,4,1,5 Charlie,3,2,5 Example of the sequence is the file 1.txt: AAGGTAAGTTTAGAATATAAAAGGTGAGTTAAATAGAATAGGTTAAAATTAAAGGAGATCAGATCAGATCAGATCTATCTATCTATCTATCTATCAGAAAAGAGTAAATAGTTAAAGAGTAAGATATTGAATTAATGGAAAATATTGTTGGGGAAAGGAGGGATAGAAGG Implement/modify the following functions: Modify the function readData, which will now take an additional parameter: a string representing the filename containing the database of individuals and their STR counts. It will also return a bool indicating if opening the file was successful or not: bool readData(string filename, vector<string>& nameSTRs, vector<string>& nameIndividuals, vector<vector<int>>& STRcounts) Update the function…Pointers are by default passed by value in a function. Group of answer choices True False ================= Given the below code segment, which of the following would allow you to deallocate all memory allocated to the pointer numbers? int* numbers = new int[5]; Group of answer choices delete[] numbers; delete numbers; delete[5] numbers; None of these ========== Consider the following code: int arr[][4] = { {1, 2, 3, 4}, {7, 8, 9, 10} }; cout << arr[1] << endl; What will be the output? Group of answer choices 1 7 Address of 1 Address of 7 Compilation error: Second [] bracket missing with arr
- Implement the following functions. Each function deals with null terminated C-Style strings. You can assume that any char array passed into the functions will contain null terminated data. Place all of the functions in a single file and then (in the same file) create a main() function that tests the functions thoroughly. You will lose points if you don't show enough examples to convince me that your function works in all cases. Please note the following: You may not use any variables of type string. This means that you should not #include <string>. Also, you may not use any c-string functions other than strlen(). If you use any other c-string functions, you will not get credit. Note, however, that functions such as toupper(), tolower(), isalpha(), isspace(), and swap() are NOT c-string functions, so you can use them. Also note that this prohibition is only for the functions that you are assigned to write. You can use whatever you want in your main() function that tests the…Implement the following functions. Each function deals with null terminated C-Style strings. You can assume that any char array passed into the functions will contain null terminated data. Place all of the functions in a single file and then (in the same file) create a main() function that tests the functions thoroughly. You will lose points if you don't show enough examples to convince me that your function works in all cases. Please note the following: You may not use any variables of type string. This means that you should not #include <string>. Also, you may not use any c-string functions other than strlen(). If you use any other c-string functions, you will not get credit. Note, however, that functions such as toupper(), tolower(), isalpha(), isspace(), and swap() are NOT c-string functions, so you can use them. Also note that this prohibition is only for the functions that you are assigned to write. You can use whatever you want in your main() function that tests the…1. Inspect the code and in your own interpretation, describe the reason call to functionChangeIt_1(n) will not change x in main()? 2. Inspect the code and in your own interpretation, describe the reason parameter n inChangeIt_2(int *n) is a pointer, and statement in the function is *n = 6 ? 3. Write a function called void swap with two parameters, which will receive the addressof x and y as pointer. The function should swap the value of x and y only if x is larger thany. Print the value of x and y after the function call. 4. Write a function called double getAverage(int *array, int SIZE), whereit accept the array as pointer, and return the average of the array. Print the returnedvalue from this function. Always use *array rather than subscript to access the arrayvalue.
- Instructions: 1. Submission deadline6/1/20232. If you copy from others zero will be given. 3. Assignment should be written with neat handwriting on proper A4 papers. 4. Upload the handwritten assignment in the blackboard, and submit the written Assignment physically. Q1) Consider the following code: intn=10, m:m=2⋅(n+m)What is the values ofmandn? Answer: Q2) Determine the error and rewrite the correct code for the following function declaration; char Total(intx,y, intz) \{ ints=x+y+z; returns; Answer: Q3) Exercise: Write a function that take your name and print a message say: Welcome, your name. Answer: Q4) Consider the following statements: struct studentName string first; string last; i; int main0 studentName st1, st2; Mark the following statements as valid or invalid. If a statement is invalid, explain why. a. st1.first="William"; b. st 1.last="Smith"; c. cin≫>st2; d. coutC++code to store the first component of products as follows: partName :printer, price : 150 c. Write…1 - Nuclear Power Plant (python) The nuclear powerplant at Threeyedfish will automatically run a program to print a warning message when the reactor core becomes unstable. The warning message reads: NUCLEAR CORE UNSTABLE!!! Quarantine is in effect. Surrounding hamlets will be evacuated. Anti-radiationsuits and iodine pills are mandatory. Since the message contains crucial information, it should be printed three times. To do this, write a function that prints this message. This function has to be used three times.You are required to make changes in the below programs and introduce the use of compaction where required. FIRST-FIT #include<stdio.h> #include<conio.h> #define max 25 void main() { int frag[max],b[max],f[max],i,j,nb,nf,temp; static int bf[max],ff[max]; clrscr(); printf("\n\tMemory Management Scheme - First Fit"); printf("\nEnter the number of blocks:"); scanf("%d",&nb); printf("Enter the number of files:"); scanf("%d",&nf); printf("\nEnter the size of the blocks:-\n");for(i=1;i<=nb;i++) { printf("Block %d:",i); scanf("%d",&b[i]); } printf("Enter the size of the files :-\n");for(i=1;i<=nf;i++) { printf("File %d:",i); scanf("%d",&f[i]); } for(i=1;i<=nf;i++) { for(j=1;j<=nb;j++) { if(bf[j]!=1) { temp=b[j]-f[i]; if(temp>=0) { ff[i]=j; break; } } } frag[i]=temp; bf[ff[i]]=1; } printf("\nFile_no:\tFile_size :\tBlock_no:\tBlock_size:\tFragement"); for(i=1;i<=nf;i++) printf("\n%d\t\t%d\t\t%d\t\t%d\t\t%d",i,f[i],ff[i],b[ff[i]],frag[i]); getch(); }