When given a c-string reference and a character

Assignment Help C/C++ Programming
Reference no: EM13164499

Write a program that implements and tests the following functions for use with C-strings (you may assume that  input obtained by the program is limited to a maximum of 80 characters):
int charcnt(char* ptr, char c);
This function, when given a C-string reference and a character, returns the number of times that the specified  character   occurred   in   the   string.
int repeat(char* ptr);
This function, when given a C-string reference, returns the number of repeated characters that occur in the string.   For   example,   the string   "Mississippi"   has   three   repeated   characters. Do   not   count   repeated   blanks   in   the string.If a character occurs more than two times, it should still only count as one repeated character; thus, "hisssss" would have only one repeated character.
void reverse(char* ptr);
This   function when given a C-string, will reverse that character string. For example, "Harry"  becomes "yrraH".  
  
Please note that you are NOT to use any prewritten C-string functions (e.g. strlen) as the purpose of this  
problem is to get experience in writing such functions. You are to use cin.getline   to   read   in   the   string   and  
cin.get to read in the character as shown below:  
  
Example run (with user input indicated with bold italics):         
Enter a string: The Mississippi Snake goes "hisssss, y'all."
Enter a character: s
The character 's' appears 10 times in the string.
There are 5 repeated characters in the string.
The reverse string is: ".lla'y ,sssssih" seog ekanS ippississiM ehT

Test   Run   #1:   
Enter a string: Mr. Boone is a bookkeeper in Mississippi.
Enter a character: s
The character 's' appears 5 times in the string.
There are 7 repeated characters in the string.
The reversed string is: .ippississiM ni repeekkoob a si enooB .rM
  
Test   Run   #2:   
Enter a string: The quick brown fox jumps over the lazy dog.
Enter a character: e
The character 'e' appears 3 times in the string.
There are 0 repeated characters in the string.
The reversed string is: .god yzal eht revo spmuj xof nworb kciuq ehT

Reference no: EM13164499

Questions Cloud

Hierarchy chart and then plan the logic : Draw the hierarchy chart and then plan the logic for a program needed by the sales manager of The Henry Used Car Dealership. The program will determine the profit on any car sold
What is the percent yield for the reaction : If 352 g of magnesium reacts with excess oxygen to produce 296 g of magnesium oxide, what is the percent yield for the reaction?
How many grams of dry nh4cl need to be added : How many grams of dry NH4Cl need to be added to 2.10L of a 0.500 M solution of ammonia, , to prepare a buffer solution that has a of 8.84? Kb for ammonia is 1.8*10^-5.
Compute the han and an- ion molar equilibrium concentrations : For each solution, determine the number of moles of HAn and of An- ion at equilibrium. For each solution, caluate the HAn and An- ion molar equilibrium concentrations. Determine the reciprocal of the An- ion concentration for each solution.
When given a c-string reference and a character : Write a program that implements and tests the following functions for use with C-strings (you may assume that  input obtained by the program is limited to a maximum of 80 characters):
Struct definition to represent the data of a person''s bank : Define a struct definition to represent the data of a person's bank account. There will be one string for the name, and two doubles for balance and interest rate. Declare two variables of this new type in the main function. Modify the values of each ..
What is the new concentration of the acid : A bottle of 6 M acid has 34.3 mL remaining in it. If the acid is diluted to 770 mL, what is the new concentration of the acid.
State stretch is definitive evidence that a compound lacks : The absence of an alkene C=C IR stretch is definitive evidence that a compound lacks an alkene functional group.
Find molecular mass by freezing point depression : Molecular Mass by Freezing point Depression (Preliminary Lab).

Reviews

Write a Review

C/C++ Programming Questions & Answers

  Complete the design and implementation

Complete the design and implementation of the class customerType defined in the Programming Example Video Store. b. Design and implement the class customerListType to create and maintain a list of customers for the video store.

  Give students practice in writing and calling their function

To give students practice in writing and calling their own functions. To give students practice in implementing and planning complex programs.

  Program to print out invalid number to character

The integer must contain 3 distinct non-zero number, or the program will print out invalid number.it should print out invalid query.

  Write a function that takes an integer array

1. Write a function that takes an integer array and the array's size as parameters. The function will check if the array is sorted. If it is, it will return a 1. If it is not sorted it will return 0. The function should not  sort the array.

  Write a program that skip s leading whitespace character

a) Write a program that skip s leading whitespace character s in each line of the pro vided data file CPPHumor .txt . Save the results in a new file

  Two types of constructors

Explain what constructors do and when they are executed. Explain the two types of constructors. Provide an example class that includes both types of constructor functions and demonstrate how an object would be instantiated using both types of constru..

  Write a program to find that number for nguyen.

In some Asian countries, 8 and 6 are considered lucky digits. Any number containing only 8s and 6s is considered lucky number, e.g. 6, 8, 66, 668, 88, 886 .... Nguyen is a student who likes mathematics very much. Nguyen likes lucky numbers but only o..

  Prepare an arbitrary sinusoidal waveform

Create a program to compute the derivative of an arbitrary input function, with arbitrary duration and arbitrary limits

  Program that compares the number of possible sequences

Write a c++ program that compares the number of possible sequences of the length L that can be generated. The program must output a formatted list comparing the number of possible sequences for L=5,6,7,8,9. given size N=9

  Write a program that asks the user to enter the names of 3

Write a program that asks the user to enter the names of three salesmen. The program should thenaccept the sales produced for salesman for each quarter of the year. Display the name, and the totalsales amount, of each salesman.

  Write a c program that reads in five numbers

Q1. (Bar Chart /Histogram printing) Write a C program that reads in five numbers (each between 1 and 30). For each number read, your program should print a line containing that number of adjacent asterisks. For example, if your program reads the numb..

  Computing value of the return statement

In the following code snippet, what is the value of the return statement for x = 4 and n = 4? int foo(int x, int n)

Free Assignment Quote

Assured A++ Grade

Get guaranteed satisfaction & time on delivery in every assignment order you paid with us! We ensure premium quality solution document along with free turntin report!

All rights reserved! Copyrights ©2019-2020 ExpertsMind IT Educational Pvt Ltd