C How to Program (8th Edition)
8th Edition
ISBN: 9780133976892
Author: Paul J. Deitel, Harvey Deitel
Publisher: PEARSON
expand_more
expand_more
format_list_bulleted
Question
Chapter 21, Problem 21.18E
Program Plan Intro
Program Plan:
- Include necessary header files.
- Start “main()” function.
- Declare two arrays to get input.
- Use getline() function to get input in array “ a ”, with delimiter being ‘c’.
- Use peek function to display next character in the input stream.
- Use get() function to get input in array “ b ”, with delimiter being ‘c’.
- Use peek function to display next character in the input stream.
- Display both the strings entered.
- Use strlen() function to calculate the length of input, add one to it and check if it is a null character. It will tell that if the string ends with null character or not.
- Return an exit the program
Program Description:
The followingprogram checksfunctionality of getline() and get() function.
Expert Solution & Answer
Want to see the full answer?
Check out a sample textbook solutionStudents have asked these similar questions
(Difficulty Level 3)Write a function frequency_match(text, chars) that receives a string text and a dictionary chars that has characters as keys and numbers as values. The function must return a list with all the characters that occur in the text as many times as their associated value in the char dictionary.
Not all the chars in the text will be present in the dictionary, but you may assume that all the chars in the dictionary are in the text. You are allowed to change the values in the dictionary.
solve using python
(python question)
Please help with this exercise I found on the internet. I want to know the solution, also with explaining( can use # in the coding),thanks
Chapter 21 Solutions
C How to Program (8th Edition)
Ch. 21 - (Write C++ Statements) Write a statement for each...Ch. 21 - (Inputting Decimal, Octal and Hexadecimal Values)...Ch. 21 - Prob. 21.8ECh. 21 - Prob. 21.9ECh. 21 - Prob. 21.10ECh. 21 - Prob. 21.11ECh. 21 - (Converting Fahrenheit to Celsius) Write a program...Ch. 21 - In some programming languages, strings are entered...Ch. 21 - Prob. 21.14ECh. 21 - Prob. 21.15E
Knowledge Booster
Similar questions
- - In C++ using Visual Studio - Seperate the files if there is any .cpp, .main or .h files. PART 1Read the contents of the text file and store them in a C++ data structure called std::map<string, int>This map is a collection of sorted <key, value> pairsIn this case, the keys are unique words found in the text file, and the values represent the number of times each word appearsFor example, since the word "cat" appears twice in the file, then map["cat"] = 2 PART 2Iterate through the map and print each key in the order they appearThis will give you a sorted list of unique wordsHere's the expected result: "a big cat does everything feeding goats helping injured juvenile kangaroos locating missing notorious objects playing quietly reading superb tales upvoting videos with xylophone yielding zebras" PART 3Iterate through the map again, this time printing each associated valueThe values represent how many times each word was found in the text filePay attention to the sequence of…arrow_forwardii) WAP to demonstrate the use of foreach loop on an array of strings, declare an array of strings and print all strings in output using foreach loop only. In Perl programming language.arrow_forward(GREATEST COMMON DIVISOR) The greatest common divisor of integers x and y is the largest integer that evenly divides into both x and y. Write and test a recursive function gcd that returns the greatest common divisor of x and y. The gcd of x and y is defined recursively as follows: If y is equal to 0, then gcd (x, y) is x; otherwise, gcd (x, y) is gcd (y, x % y), where % is the remainder operator.arrow_forward
- 10. Write the Caesar cipher function. Need C, C++, Java, Python, or Perl code for the below question. Important: Do not copy codes from prepinsta.com.arrow_forwardUsing C programming language: Modify the last assignment to read and write a file of comma seperated values (.csv file, which could be read into Excel). We assume you will not have a book that has a comma in it's title (not a good assumtion in general). The strchr() function will return the index of given character in a string. This is one way to find the ',' in a string. Your function to print out all entries should also print out a number for each item. Then add a function which can delete an item using this number.arrow_forwardComplete the following function using pass-by-reference: void findMax(int &max, int a) which assigns value ‘a’ to ‘max’ if a > max. Write a pseudo-code then implement a program in C language to find the maximum in a sequence of numbers using this function.arrow_forward
- (Note: USE ONLINE C COMPILER) Please help. Provide screen shot of input and output. Thank you.arrow_forward(Refer to the picture for directions)(My code produces no output)My code: Main.cpp #include<iostream> #include <fstream> #include <vector> #include <string> #include "StatePair.h" using namespace std; int main() { ifstream inFS; int zip; int population; string abbrev; string state; unsigned int i; vector<StatePair <int, string>> zipCodeState; vector<StatePair<string, string>> abbrevState; vector<StatePair<string, int>> statePopulation; inFS.open("zip_code_state.txt"); if (!inFS.is_open()) { cout << "Could not open file zip_code_state.txt." << endl; return 1; } while (!inFS.eof()) { StatePair <int, string> temp; inFS >> zip; if (!inFS.fail()) { temp.SetKey(zip); } inFS >> abbrev; if (!inFS.fail()) { temp.SetValue(abbrev); } zipCodeState.push_back(temp); } inFS.close(); inFS.open("abbreviation_state.txt"); if…arrow_forward(Recursive Greatest Common Divisor) The greatest common divisor of integers x and y isthe largest integer that evenly divides both x and y. Write a recursive function gcd that returns thegreatest common divisor of x and y. The gcd of x and y is defined recursively as follows: If y is equalto 0, then gcd(x, y) is x; otherwise gcd(x, y) is gcd(y, x % y), where % is the remainder operator.arrow_forward
- write code in c++ pleasearrow_forwardUSE C++ (Display matrix of 0s and 1s) Write a function that displays an n-by-n matrix using the following header: void printMatrix(int n) Each element is 0 or 1, which is generated randomly. Write a test program that prompts the user to enter n and displays an n-by-n matrix. Here is a sample run:arrow_forwardHello, How can I store a whole book in a file in c language? I had some issues because the string is too long. here is the question: For this assignment I have uploaded a large text file that contains the entire book “Robinson Crusoe” byWilliam Defoe as file defoe-robinson-103.txt Consider the code shown below. It uses the fgets function.fgets is used to read (“get”) strings (“s”) from a file (“f”), hence the name “fgets”. It takes the following arguments:1. A pointer to an array large enough to store the string. In our case that is the char array calledbuffer of size MAX.2. The size of the array, in our case the symbolic constant MAX, set equal to 4000 in line 4.3. The file pointer of the file to read from, in our case bkPtr. Each call to fgets returns a string until the newline (“\n”) character or EOF is encountered. The codereads strings from the file defoe-robinson-103.txt in the while loop and prints them to screen.Implement this program and run it.arrow_forward
arrow_back_ios
SEE MORE QUESTIONS
arrow_forward_ios
Recommended textbooks for you
- C++ Programming: From Problem Analysis to Program...Computer ScienceISBN:9781337102087Author:D. S. MalikPublisher:Cengage Learning
C++ Programming: From Problem Analysis to Program...
Computer Science
ISBN:9781337102087
Author:D. S. Malik
Publisher:Cengage Learning