Share
Explore BrainMass

C++

Bjarne Stroustrup, prime developer of C++

Developed in 1979 in Bell Labs by one Bjarne Stroustup, C++ is essentially a super set of the C language, enhanced by the additional support of classes and other object-orientated features that are not well-supported in C. Like C, it is an intermediate language, consisting of both high- and low-level language features. Other similarities with C include being statically-typed, being operable as a procedural language and fine control over memory management. Unlike languages that intend to hide memory management details from the programmer, like Java, Perl, PHP and RubyC++ supports four types of memory management: static memory allocation, automatic memory allocation, dynamic memory allocation and the boehm garbage collector.

C++ is in wide use today (even here on BrainMass, where it is one of the top-visited categories in Computer Science) and has been used to craft a huge variety of programs. Its applications include operating system platforms, system software, application software, device drivers, embedded software and high-performance server and entertainment software, all thanks to it being a highly efficient compiler to native code, and therefore able to run faster in many cases than more portable languages like Java.

As one would expect for such a staple language, C++'s features include over 35 operators, including ones that can cover basic arithmetic, bit manipulation, indirection, comparisons, logical operations and many more. Almost all of these may be overloaded for user-defined types for added functionality - the few exceptions being the member access and conditional operators. This ability to overload operators is essential to many advanced C++ programming techniques, giving the language ever higher capabilities. Overloading an operator does not change the precedence of calculations involving the operator, nor does it change the number of operands of an operator uses. Overloaded “&&: and “||” operators lose their shirt-circuit evaluation property.

Passing array as parameter for finding the count of odd numbers

This question has three parts. 1. Write a function that takes an array of int as a parameter and returns a count of odd numbers in the array. Assume the array has MAX elements where MAX is a global constant int. That means that before all of the functions there is a declaration like: const int MAX = 10; An

Simulator in C++ Testing New Biological Triggering Device

A local government organization has been testing a new biological triggering device. The actual cost has gotten out of hand and they have recruited you to test the new style trigger through simulation. The trigger device is a 20 by 20 grid where each square is a sensor. Each square in the grid starts with one flea. All the fl

C++ program for variation of Caesar's substitution cipher

The caeser cipher, which shifts all letters by a certain amount, is easy to decipher. Try this, instead of numbers use letters. Consider this, the word is FEATHER. Remove duplicate letters, making FEATHR, and append the rest of the letters of the alphabet in reverse order. Now encrypt the letters as follows: Now, write a progr

Answering 5 C++ language questions focusing on arrays and strings

Do #2, 4, 6, 8, 10 on pages 574 - 577 of C++ a single Microsoft Word file 2. Consider the following declaration: double passwords[100]; In this declaration, identify the following: a. The array name b. The array size c. The data type of each array component d. The range of values for the index of the array 4. Dete

C++ Numbers Class to Translate Number to English Description

Need help with this C++ program code: Numbers Class I need the source.cpp code and explanation on how you got it. Numbers Class Design a class Numbers that can be used to translate whole dollar amounts in the range 0 through 9999 into an English description of the number. For example, the number 713 would be translated in

C++ Structure to Store the Weather Data

Please I need the source.cpp code Write a program that uses a structure to store the following weather date for a particular month: Total Rainfall High Temperature Low Temperature Average Temperature The program should have an array of 12 structures to hold weather date for an entire year. When the program runs, it sho

Binary tree and heap problems

I need help with the following in order to study for my test. The last time you were able to explain the lists so that I did well so I hope to be able to get the same results. 1.Show the order in which the nodes in the tree, which I included in the attachment are processed by a. an inorder traversal of the tree. b. a postor

Binary tree and Heap programs

I need help with this assignment for my discussion forum. It says to write a program to take n elements and insert them into a heap one by one. Include a function to print out the elements in the heap.

Recursive functions

A sequential search member function of SortedType has the following prototype: void SortedType: : Search(int value, bool& found) ; a. Write the function definition as a recursive search, assuming a linked list implementation. b. Write the function definition as a recursive search, assuming an array-based implementation.

Implement the specification for an integer function

Implement the following specification for an integer function in the client program that returns the number of items in a queue. The queue is unchanged. int GetLength(QueType queue) Function: Determines the number of items in the queue. Precondition: queue has been initialized. Postconditions: queue is unchanged. Functio

Linked Lists with arrays

Use the linked lists contained in the array pictured in Figure 6.19 to answer the following questions: a. What elements are in the list pointed to by list1? b. What elements are in the list pointed to by list2? c. What array positions (indexes) are part of the free space list? d. What would the array look like after the dele

Merged Lists

Write a client function that merges two instances of the Sorted List ADT using the following specification. MergeLists(SortedType list1, SortedType list2,SortedType& result) Function: Merge two sorted lists into a thirdsorted list. Preconditions: list1 and list2 have been initialized and are sorted by key using function

C++ code to implement SplitLists

I need help with this question so that I can use it to study for my midterm. An Unsorted Type ADT is to be extended by the addition of function SplitLists, which has the following specifications: SplitLists(UnsortedType list, ItemType item, UnsortedType& list1, UnsortedType& list2) Function: Divides list into two lists a

Using Stacks to check for balance symbols

I need help with this program and maybe a small explanation: Write a small program that will check for balancing symbols in C++. Look for: •/* */ •( ) •[ ] •{ } See if you can display an error message that will describe the problem and point to the possible problem section of code.

C++ Count Number of Letters in a Text File

I need help with this program. I need to create an array of 26 components to do the letter count for the 26 letters in the alphabet and a variable for the line count. (You may wish to call these variables letterCount and lineCount respectively.) Hint: Use the plan of declaring variables, opening input and output files, initializ

C++ absolute value template and program

Create a function template that computes and displays the absolute value of a passed argument. (By "absolute value" we mean that the template returns the number with no sign, whether the passed argument number is positive or negative.) Create a program that uses this function template, passing in two arguments of type int, f

Tortoise and Hare Race Simulation using a random number generator

Create a simulation race between the tortoise and the hare. For this project, use random-number generation to move the creatures. To make things more interesting, the animals have to race up the side of a slippery mountain, which could cause them to lose ground. In this race either animal could win or there could be a tie with n

Derive the cube class from the base square class.

Derive the cube class from the base square class. Assume the square class has a protected member variable representing the side called side and declared as a double with a default value of 1.0. It also has a public function called calcVal that evaluates the area of a square as side * side. In your derived class have the defau

A complete c++ program for swapping operations

Create a template that changes the value of 2 variables. (Hint: Use reference parameters since you will swap the variables within the function.) Use the template in a program where you change the value of 2 variables of type int and 2 variables of type long.

C++ Class Compositon

Create a class that simulates an alarm clock. In this class you should: - Store time in hours, minutes, and seconds. Note if time is AM or PM. (Hint: You should have separate private members for the alarm and the clock. Do not forget to have a character variable representing AM or PM.) - Initialize the clock to a specified t

c++ program for performing division operations

I need to create a program titled Division. Here are the specifics: Have the program prompt the user "Enter numerator and denominator" and store the two values entered. (If you wish the user to "Enter numerator/denominator" be sure to adjust your data gathering variables to include a holder variable for the slash character.)

C++ program with class and 2 constructors

I need help to create a program that does the following: Create a person class to represent a person. (Call the class personType.) To simplify things, have the class have 2 variable members for the person's first and last name. Include 2 constructors. One should be a default constructor and the other should be one with paramete

C++ Program

Write a program that: a. Randomly generates the daily temperature (in F) of two cities A and B the month of July. The temperatures are integers in the range [60.. 90] and they are stored in two arrays tA and tB. b. Calculate the average temperature for the month in each city. c. How many days was the temperature above the

C++ code for calculating revenue

Define a class called Revenue that has 2 private members of demand and price. Include a constructor and a public function that calculates the RevenueValue of the class. RevenueValue = demand * price Use public functions of the class in a program that computes RevenueValue and displays RevenueValue when demand is 2000 and price

Look up 1000 random numbers using linear search on the original data and 1000 numbers using the binary search. Determine the average number of probes that each search algorithm took. Do these values represent the theoretical values?

I need help in making a program that: - generates a list of 5000 numbers stored in an array with values between 1 and 5000, - prints out the middle original 200 numbers to show the results (not one number per line), - sorts the numbers using bubble sort, - sorts the original numbers again using quick sort. How many swap

HashTable search

I have a book search program that requires us to read in data from a file into our program and search by title, author, or ISBN. I need help getting the data from the data file to work correctly with the program. Please see the attached documents.