C++ How to Program (10th Edition)
10th Edition
ISBN: 9780134448237
Author: Paul J. Deitel, Harvey Deitel
Publisher: PEARSON
expand_more
expand_more
format_list_bulleted
Want to see more full solutions like this?
Subscribe now to access step-by-step solutions to millions of textbook problems written by subject matter experts!
Want to see the full answer?
Check out a sample textbook solutionStudents have asked these similar questions
Q1. What is the difference between static and extern storage class? Give suitable examples in support of your answer.
Q2. Write a program to take input for a number, if the number is palindrome, then display its half on the screen, otherwise take input for 2 more numbers, and display their product on the screen. Use minimum two functions including main function
- Print the Movie names, list of actors/actresses, ratings(number of tickets sold), ticket prices, cost of production and the total net profit of each movie(net_profit_of_movie)b) Write a function that calculates the net_profit_of_movie; which is the multiplication of ticket prices and ratings(number of tickets sold), subtracted by cost of production c) In main call function, print all movies’ information and the net_profit_of_movie to the console. d) Create a file called movies.txt and write all movies information to the file, including the net_profit_of_movie per movie. e) Ask the user to add more movies (use realloc). The user needs to write at least 1 more movie (e.g. movie 4) then get all information for the new movies from the user. Create a file called UpdatedMovies.txt and write all movie data including the lately added movies’ data onto the file UpdatedMovies.txt.f) Write (Mohammad) and (63223) at the top of the code. g) Write explanatory comments for your code
3. A. The following transfer statements specify a memory. Explain the memory operation in each case.
i. M[AR] R5
ii. R1 M[R5]
iii. R2 M[AR]
Chapter 14 Solutions
C++ How to Program (10th Edition)
Ch. 14 - (Fill in the Blanks) Fill in the blanks in each of...Ch. 14 - (File Matching) Exercise 14.3 asked you to write a...Ch. 14 - (File Matching Test Data) After writing the...Ch. 14 - Prob. 14.8ECh. 14 - (File-Matching Enhancement) Its common to have...Ch. 14 - Write a series of statements that accomplish each...Ch. 14 - Prob. 14.11ECh. 14 - (Telephone-Number Word Generator) Standard...Ch. 14 - (sizeof Operator) Write a program that uses the...Ch. 14 - Prob. 14.14MAD
Knowledge Booster
Learn more about
Need a deep-dive on the concept behind this application? Look no further. Learn more about this topic, computer-science and related others by exploring similar questions and additional content below.Similar questions
- You are required to make changes in the below programs and introduce the use of compaction where required. #include<stdio.h> #include<conio.h> main() { int ms, bs, nob, ef,n, mp[10],tif=0; int i,p=0; clrscr(); printf("Enter the total memory available (in Bytes) -- "); scanf("%d",&ms); printf("Enter the block size (in Bytes) -- "); scanf("%d", &bs); nob=ms/bs; ef=ms - nob*bs; printf("\nEnter the number of processes -- "); scanf("%d",&n); for(i=0;i<n;i++) { printf("Enter memory required for process %d (in Bytes)-- ",i+1); scanf("%d",&mp[i]); } printf("\nNo. of Blocks available in memory -- %d",nob); printf("\n\nPROCESS\tMEMORY REQUIRED\t ALLOCATED\tINTERNAL FRAGMENTATION"); for(i=0;i<n && p<nob;i++) { printf("\n %d\t\t%d",i+1,mp[i]); if(mp[i] > bs) printf("\t\tNO\t\t---"); else { printf("\t\tYES\t%d",bs-mp[i]);tif = tif + bs-mp[i]; p++; } } if(i<n) printf("\nMemory is Full, Remaining Processes cannot be accomodated"); printf("\n\nTotal…arrow_forward-Write a C++ program with the following functions, with the correct number of arguments for each function, as well as any other functions used in class. void fillUpArray ( argument1, argument2) This function should read in a text file called "theVillagers.txt" (You may download it on Canvas). "theVillagers.txt" is a text file of numbers in ascending order, ranging anywhere from 1 to 2500, nonrepeating. Each number is separated by a new line character. The very first number in the text file is a number that refers to how many entries are in the rest of the text file. This function should populate an array with all the remaining entries in the text file, but it should NOT declare any arrays itself and it should not reference any global variables. void getInput(argument1, argument2) This function should read in a text file of the user's choosing into a given array. It should discard excess input. You may assume that there are always 2000 entries in this text file being entered. void…arrow_forwardPractice problem we were given in C++ to review for test. Thanks Write a program that reads data from a data file, the value of which is provided at the end of the problem. Your program is to incorporate the following requirements: Data to the program is input from a file of an unspecified length; that is, the program does not know in advance how many numbers are in the file. Save the output of the program in a file. Write a function called getNumber which reads a number from the input file, outputs the number to the output file and the monitor and sends the input number to the function main. Make sure, both input and out file are being opened in the main program. Write a function called classifyNumber which counts number of even, odd, and zero (occurrences of zero) available in the input file. Have the program find the sum and average of the numbers and print only 10 numbers per line. Write a function called printResult so that it outputs (in output file and monitor) even number of…arrow_forward
- C++ Programming How many bits in a byte? multiples of 8 bit How many bytes in a double? __________ When assigning a float variable to an int variable, what is lost? __________ In the statement x = y; which variable is updated, x or y? _____ What include file is needed to make use of vector variables? ________ Give an example of a unary operator and a binary operator. _________ Write a line of code that declares an int type of variable and initializes it to the value 23. ____________________________ A variable declared outside of any function is called a __________ variable. You end a multi-line comment with ______________. What do you call the variable RATE in the following statement: const double RATE = 0.75; _________________________ What is the function performed by the cout object? ____________________ You can put several statements on the same line, true or false? _______ Write a single statement that outputs two variables x and y to the screen. _____________________ After the…arrow_forwardCan't get the following code to run because of two int mains, but don't know how to consolidate it together //<File name> -- brief statement as to the file’s purpose//xxxx-<xxx> ADD YOUR SECTION NUMBER//<Sources if necessary>#include <iostream>#include <string>using namespace std;//Global declarations: Constants and type definitions only -- no variables//Function prototypesint main(){//In cout statement below SUBSTITUTE your name and lab numbercout << "xxxx -- xxxx" << endl << endl;//Variable declarations//Program logic//Closing program statementssystem("pause");return 0;}//Function definitions#include<math.h>using ll = long long;ll ans = 0;int gray_code(int n) {return n ^ (n >> 1);} int count_bits(int n) {int res = 0;for (; n; n >>= 1)res += n & 1;return res;} void all_combinations(int n, int k) {for (int i = 0; i < (1 << n); i++) {int cur = gray_code(i);if (count_bits(cur) == k) {ans++;}}} int…arrow_forwardIn Python, Use the file scores.txt (below) to help with the coding problem.! scores.txt ——————— John -3 Paul 3 Sue 2 ——————- utilize the follow function headers: Main() WriteScores() ReadScores() First, the main function will ask the user, “do you want to record scores or read scores?” Depending on what the user inputs, the answer will determine whether to call WriteScores OR ReadScores. The WriteScores function will then ask the user, “how many scores do you want to add?”. The function will then read each of the players name and score as keyboard input, then save these as records in a file named scores.txt. Sample output: Do you want to read scores or write scores? Type r or w: r Name: John Golf Score: -2 Name: Paul Golf Score: -1 Name: George Golf Score: - 4arrow_forward
- In Python, Use the file scores.txt (below) to help with the coding problem.! name.txt ——————— John -3 Paul 3 Sue 2 ——————- utilize the follow function headers: Main() WriteScores() ReadScores() First, the main function will ask the user, “do you want to record scores or read scores?” Depending on what the user inputs, the answer will determine whether to call WriteScores OR ReadScores. The WriteScores function will then ask the user, “how many scores do you want to add?”. The function will then read each of the players name and score as keyboard input, then save these as records in a file named scores.txt. Sample output: Do you want to read scores or write scores? Type r or w: r Name: John Golf Score: -2 Name: Paul Golf Score: -1 Name: George Golf Score: - 4arrow_forwardThe goal for this question: DISCLAIMER****** CODE MUST BE WRITTEN IN C CODE. NOT C++, C#, etc. To create a program that MUST utilize the functions (argc, argv, char strstr, and possibly even Getline) to, 1. Open a file 2. Read the file 3. Read txt file line by line 4. count up the number of times a specified word is read(HOWEVER! IT CANNOT COUNT MORE THAN ONE WORD PER LINE!) ex. if the code comes across a line in a text file that has the word cookie in it 3 times. It can only count the word ONCE since it is counting line by line. Not all the words added up. 5. then display to the user the total number of lines with the specific word. ex. gcc -o <program name> ./<program name> <file name.txt> <"word to be searched"> then execute a total number of times words came up. Again, only count up by one even if there is that specified word multiple times in one line.arrow_forwardComplete the following questions about different types of variables:i. Check the last digit of your id number(123456789). If it is even or 0, fill the gap in (A)with the word global (i.e., static global), otherwise, fill it with local (i.e., static local).Then, complete Table I. ii. In a multi-source program, there is a fileA.c that contains variables and functions,and a fileB.c that contains the main function, as well as usage of some of theresources found in fileA.c. Explain:a) fileA.c has a global variable called my_variable, that should only beaccessed within the file. I.e., no other files should be able to access thatvariable.How should my_variable be declared inside of the file, in order to guaranteethis functionality? b) fileA.c also has a global variable called my_shared_variable, which canand should be accessible from other files, including fileB.c.How should my_shared_variable be declared in order to allow thisfunctionality?Note for item ii): You also need to state in a…arrow_forward
- Please use Python for this question. Please make sure the code is formatted correctly in Python as well. Write a standalone function partyVolume() that takes accepts one argument, a string containing the name of a file. The objective of the function is to determine the Volume object that is the result of many people at a party turning the Volume up and down. More specifically: the first line of the file is a number that indicates the initial value of a Volume The remaining lines consist of a single character followed by a space followed by a number. The character will be one of ‘U” or ‘D’ which stand for “up” and “down” respectively. The function will create a new Volume object and then process each line of the file by calling the appropriate method of the Volume object which changes the value of the Volume. The function then returns the final Volume object. Guidelines/hints: This is a standalone function, it should NOT be inside (indented within) the class. It should be…arrow_forwardCreate 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…arrow_forwardPlease use Python for this question. Please make sure the code is formatted correctly in Python as well please. Write a standalone function partyVolume() that takes accepts one argument, a string containing the name of a file. The objective of the function is to determine the Volume object that is the result of many people at a party turning the Volume up and down. More specifically: the first line of the file is a number that indicates the initial value of a Volume The remaining lines consist of a single character followed by a space followed by a number. The character will be one of ‘U” or ‘D’ which stand for “up” and “down” respectively. The function will create a new Volume object and then process each line of the file by calling the appropriate method of the Volume object which changes the value of the Volume. The function then returns the final Volume object. Guidelines/hints: This is a standalone function, it should NOT be inside (indented within) the class. It should…arrow_forward
arrow_back_ios
SEE MORE QUESTIONS
arrow_forward_ios
Recommended textbooks for you
- 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
C++ for Engineers and Scientists
Computer Science
ISBN:9781133187844
Author:Bronson, Gary J.
Publisher:Course Technology Ptr
C++ Programming: From Problem Analysis to Program...
Computer Science
ISBN:9781337102087
Author:D. S. Malik
Publisher:Cengage Learning
C - File I/O; Author: Tutorials Point (India) Ltd.;https://www.youtube.com/watch?v=cEfuwpbGi1k;License: Standard YouTube License, CC-BY
file handling functions in c | fprintf, fscanf, fread, fwrite |; Author: Education 4u;https://www.youtube.com/watch?v=aqeXS1bJihA;License: Standard Youtube License