Problem Solving with C++, Student Value Edition
10th Edition
ISBN: 9780134543680
Author: Walter Savitch
Publisher: PEARSON
expand_more
expand_more
format_list_bulleted
Concept explainers
Question
Chapter 8.1, Problem 7STE
Program Plan Intro
Character string:
A character string store the collection of characters in the form of array (that is arrays of char). It is also called as “C-strings”, which is terminated by the null character.
Explanation of Solution
Given statement:
//Initialization of char array
char shortString []={'a','b','c'};
Explanation:
- In the above statement, the character array “shortString []” is initialized with the character constant “{'a','b','c'}”. In this initialization the character array is mentioned as follows:
- First, the character “a” is stored in “shortString [0]”...
Expert Solution & Answer
Want to see the full answer?
Check out a sample textbook solutionStudents have asked these similar questions
Strings in C have a terminal character at the end of the array, while integer arrays, for example, do not. Why do you believe this is the case?
The function “reverse” reverses a given string and returns a pointer to the resulting string. Complete the missing parts.
char* reverse( char* str ) {
int n, h, j, k;
char _________________;
n = strlen( _____________);
h = (n / 2);
for ( j=0, k=(n - 1); (j < h); j++, _____________________ ) {
tmp = ___________;
str[k] = str[j];
str[j] = _______________________________;
}
return ________________________;}
int main( int argc, char** argv ) {
char s[512];
strcpy( s, argv[1] );
printf( "Reverse: %s\n", reverse( s ) );
return 0;}
storage of strings through pointer saves memory space. justify your answer with an example.
Chapter 8 Solutions
Problem Solving with C++, Student Value Edition
Ch. 8.1 - Prob. 1STECh. 8.1 - What C string will be stored in singingString...Ch. 8.1 - What (if anything) is wrong with the following...Ch. 8.1 - Suppose the function strlen (which returns the...Ch. 8.1 - Prob. 5STECh. 8.1 - How many characters are in each of the following...Ch. 8.1 - Prob. 7STECh. 8.1 - Given the following declaration and initialization...Ch. 8.1 - Given the declaration of a C-string variable,...Ch. 8.1 - Write code using a library function to copy the...
Ch. 8.1 - What string will be output when this code is run?...Ch. 8.1 - Prob. 12STECh. 8.1 - Consider the following code (and assume it is...Ch. 8.1 - Consider the following code (and assume it is...Ch. 8.2 - Consider the following code (and assume that it is...Ch. 8.2 - Prob. 16STECh. 8.2 - Consider the following code: string s1, s2...Ch. 8.2 - What is the output produced by the following code?...Ch. 8.3 - Is the following program legal? If so, what is the...Ch. 8.3 - What is the difference between the size and the...Ch. 8 - Create a C-string variable that contains a name,...Ch. 8 - Prob. 2PCh. 8 - Write a program that inputs a first and last name,...Ch. 8 - Write a function named firstLast2 that takes as...Ch. 8 - Write a function named swapFrontBack that takes as...Ch. 8 - Prob. 6PCh. 8 - Write a program that inputs two string variables,...Ch. 8 - Solution to Programming Project 8.1 Write a...Ch. 8 - Write a program that will read in a line of text...Ch. 8 - Give the function definition for the function with...Ch. 8 - Write a program that reads a persons name in the...Ch. 8 - Write a program that reads in a line of text and...Ch. 8 - Write a program that reads in a line of text and...Ch. 8 - Write a program that can be used to train the user...Ch. 8 - Write a sorting function that is similar to...Ch. 8 - Redo Programming Project 6 from Chapter 7, but...Ch. 8 - Redo Programming Project 5 from Chapter 7, but...Ch. 8 - Prob. 11PPCh. 8 - Write a program that inputs a time from the...Ch. 8 - Solution to Programming Project 8.14 Given the...Ch. 8 - Write a function that determines if two strings...Ch. 8 - Write a program that inputs two strings (either...Ch. 8 - Write a program that manages a list of up to 10...
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
- In java, the Arrays class contains a static binarySearch() method that returns …… if element is found. false true (-k–1) where k is the position before which the element should be inserted The index of the elementarrow_forwardQ# Describe what a data structure is for a char**? (e.g. char** argv) Group of answer choices A. It is a pointer to a single c-string. B. It is an array of c-strings C. It is the syntax for dereferencing a c-string and returning the value.arrow_forwardQ3/ Write A program in C++ language to print multiplication of Array A and B on the screen, these arrays have 10 elements entering from keyborad?arrow_forward
- Question Aac use Syder to execute the Python code and answer the questions Code:#listsadict = {'a': 1, 'b': 2, 'c': 3, 4:'d'}print(adict)# Iterating a dictionaryfor ch in adict:print(ch) print()for ch in adict:print(adict[ch]) Questions:• Why can dictionary keys be strings or integers?• What do each of the for loops display?arrow_forwardWhat is the output of the following C++ code? unorderedLinkedList<int> list; unorderedLinkedList<int> copyList; int num; cin >> num; while (num != -999) { if (num % 5 == 0 || num % 5 == 3) list.insertFirst(num); else list.insertLast(num); cin >> num; } list.print(); cout << endl; copyList = list; copyList.deleteNode(78); copyList.deleteNode(35); cout << "Copy List = "; copyList.print(); cout << endl;arrow_forwardplease code in python You are given an array of strings arr. Your task is to construct a string from the words in arr, starting with the 0th character from each word (in the order they appear in arr), followed by the 1st character, then the 2nd character, etc. If one of the words doesn't have an ith character, skip that word.arrow_forward
- define an array of 100 ints, and write a loop ( including the body) to initialize every element in the array to 0. you can name the array whatever you'd likee 2. in c, strings have a terminating character at the end of the array, while, for exemple, integer arrays do not. why do you think this is?arrow_forwardWrite a program to reverse a given string using pointers. Your program should take a string as input and then modify the string in place so that it becomes reversed. You may use only pointer variables and not any array indexing. In c language pleasearrow_forwardWrite C++ program binary searching for search value in array list and display its position on the screen?arrow_forward
- Write a Menu driven Program which includes these operations like insertion, deletion, and fetching all the elements from an array? (write the program in c++ language, here menu-driven means you can use switch cases)arrow_forwardc++ , A character string is given. What is the minimum number of characters you need to change to make the resulting string of identical characters? Solve this task in 3 different manners using : sets, maps and deque ( 3 different codes ) Input output 69pop66 4 1+2=12 4arrow_forwardanswer this by c programming Write a program that deletes all the elements in an array which match a searchkey.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