C++ Answers

Questions answered by Experts: 9 913

Need a fast expert's response?

Submit order

and get a quick answer at the best price

for any assignment or question with DETAILED EXPLANATIONS!

Search



1.Write a program which inputs a person’s height (in centimetres) and weight (in kilograms) and outputs one of the messages: underweight, normal, or overweight, using the criteria:

Underweight: weight < height/2.5

Normal: height/2.5 <= weight <= height/2.3

Overweight: height/2.3 < weight


2.Write a program which inputs a date in the format dd/mm/yy and outputs it in the

format month dd, year.

For example, 25/12/61 becomes: December 25, 1961

3.Write a program which produces a simple multiplication table of the following format for integers in the range 1 to 9:

1 x 1 = 1

1 x 2 = 2

9 x 9 = 81

4.Write a program which inputs an integer value, checks that it is positive, and outputs its factorial, using the formulas:

factorial(0) = 1

factorial(n) = n × factorial(n-1)

5. Write a program that display numbers from 0 to 10 using three loops.










1) Create a Binary Search Tree (BST) that perform the following operations:



- Insertion of a node in BST


- Deletion of a node in BST


- Searching a node in BST




write a program to read an input file to get the number of sentences.

with specifications:

1. count 'A' and 'a' as the occurence of the leter a

2. the two same words should only be recorded once. 

3. ignore non-letter characters ( spaces, punctuation, etc)

4. do not list letters that donot occur at leasr once.

all operations must be done using dynamic array and pointers.


input file 1:

3

My dog did my homework.

My cat is not at home!

Happy New Year!


Write a C++ program that inputs the price of a shoe in a shop, then deducts the discount from the price of the shoe as follows:

20% discount if the price of the shoe is above or equal 40 BD.

10% discount if the price of the shoe is more than or equal 15 BD and less than 40 BD.

5% discount if the price of the shoe is more than or equal 7 BD and less than 15 BD.

0% discount if the price of the shoe is below 7 BD.

Then, your program should output:

The initial shoe price, the discount amount and the final shoe price after discount.

All numbers should be displayed with 2 decimal places.

3. Loading...

by CodeChum Admin


I wanna experiment on looping through a range of numbers that will be randomly inputted by the user. However, I don't want to let them see the loading percentage that is divisible by 4, so please exclude those for me when printing it out.




Thank you!






Instructions:


Input two integers in one line. The first inputted integer will be the starting point, and the second one shall serve as the ending point.

Use the power of loops to loop through the starting point until the ending point (inclusive), and print out each number within the range with the corresponding format shown on the sample output. However, skip the printing of statement if the integer is divisible by 4. Tip: Utilize the continue keyword to complete the process.

Input


A line containing two integers separated by a space.


2·10

Output


Multiple lines containing a string and an integer.


Loading...2%

Loading...3%

Loading...5%

Loading...6%

Loading...7%

Loading...9%

Loading...10%


2. Not My Favorites

by CodeChum Admin


We've already done looping through a series of numbers and printing out its squares, so how about we level it up and go with cubes this time?




I have a condition though; I don't want to be associated with numbers that are divisible by 3 or 5 so if an integer is divisible by either of the two, don't make their cube values appear on the screen, please.




Care to fulfill my request?






Instructions:


Print out the cube values of the numbers ranging from 1 to 20 (inclusive). However, if the number is divisible by either 3 or 5, do not include them in printing and proceed with the next numbers. Tip: When skipping through special values, make use of the keyword continue and put them inside a conditional statement.

Output


Multiple lines containing an integer.


1

8

64

343

512

1331

2197

2744

4096

4913

6859


Needle in the Haystack

by CodeChum Admin


Let's now try finding a certain digit into an integer! Come and join in on the fun and code with me!






Instructions:


Input two integers in one single line. The first inputted integer must be within 0-9 only.

Using loops, identify if the first inputted integer (0-9) is present in the second inputted integer. If it is found, print "Yes"; otherwise, print "No". Tip: If the number is already found even without reaching the end of the loop, use the break keyword to exit the loop early for a more efficient code.

Input


A line containing two integers separated by a space.


1·231214238

Output


A single line containing a string.


Yes


Write a program which reads a C++ source file and checks that all instances of brackets are balanced, that is, each ‘(’ has a matching ‘)’, and similarly for [] and {}, except for when they appear inside comments or strings. A line which contains an unbalanced bracket should be reported by a message such as the following sent to standard output: '{' on line 15 has no matching '}'


Write a program that will display the following pattern, given the value of n and m. Example if n = 5,and m=6, output


Write the definition of the function, leavesCount, that takes as a parameter a pointer to the root node of a binary tree and returns the number of leaves in a binary tree. Add this function to the class binaryTreeType and create a program to test this function


LATEST TUTORIALS
APPROVED BY CLIENTS