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

Write a code which demonstrates the use of hex,oct,dec manipulators



Write an algorithm to find the energy produced at every second of the reaction is allowed to happen for n seconds


You are set out travel for your "Magical Vacation" and you are given a choice to take two destinations. You draw up multiple destination starting at asingle origin with different routes. Suppose different routes from torigin are represented complete binary tree height h, with number of node, n = 2 ^h - 1, where each node and each leaf of this tree ha associated cost "c" (any arbitrary real number). The destination are leaves of the tree. You can compute the cost to destination (leaf node) by summing up avalues of the nodes on the path up root, including leaf node itself. You are to find two destination has the lowest cost as your choice for vacation ie., x,y (two leaves). you can find cost by summing up all nodes in the path up the root. nodes only once [ie., you are taking the union of the ancestors up to origin]. Write a program to compute the lowest destination pair – that is of all leaf combinations which pair gives the lowest cost. Example: C(x,y) = 9 + 15+12 + 14+19+54 =123


Question 5 (20 marks) avoid plagiarism.

Discuss Object oriented programming in c++ with 4 points. Each point shoult not be less

than 200 words.


Question 4 (25 marks) avoid plagiarism. Write the following program in c++.

i. Create a class of your own choice with 5 attributes.

ii. Create an object of named objone in the intmain() function

iii. Access attributes and set values for all the 5 attributes

iv. Print all the attribute values

v. Create a function in the class that add two number and access the function using the

oblject.

Question 5 (20 


Write the following program in c++.

Combine your first and second name and pick only the first five characters of your name for the project.

i. Declare an array named name1 and put all the first five characters into it.

ii. Write a for loop with an if condition that will find and output the index value of a

searched character in the array. Let the program be such that the user will input the character being searched for.


write a program in C++ that takes a number from user and prints the first three multiples and first three factors of that number

Write a C++ program using file handling to perform the following operations


(A) A file named “data.txt” contains number from 0 to 100. Open the “data.txt” file in read


mode.


(B) Read data from “data.txt” file.


(C) If the number is odd, open a new file named “odd.txt” and write the odd number into


“odd.txt” file.


(D) If the number is even, open a new file named “even.txt” and write the even number into


“even.txt” file.


(E) Display the data of all files.


Write a C++ program which will overload “= =” binary operator. The overload class should

contain one parameterized constructor to initialize default value to the member variable, and a

display function to display value of member variables.


(There's an error in the code when I run the program how can I fix this?)

(This is the question and the answer also answered but, there's an error, hope you could help) (Question #282822 in C++ for qq_576)


main.cpp:71:13: error: ‘_getch’ was not declared in this scope; did you mean ‘getch’?

  71 |  pin[i] = _getch();

   |       ^~~~~~

   |       getch

main.cpp:72:4: error: ‘_putch’ was not declared in this scope; did you mean ‘fputc’?

  72 |  _putch('*');

   |  ^~~~~~

   |  fputc


main.cpp:95:18: error: ‘_getch’ was not declared in this scope; did you mean ‘getch’?

  95 |   NEWpin[i] = _getch();

   |         ^~~~~~

   |         getch

main.cpp:96:6: error: ‘_putch’ was not declared in this scope; did you mean ‘fputc’?

  96 |   _putch('*');

   |   ^~~~~~

   |   fputc

main.cpp: In function ‘int main()’:

main.cpp:135:12: warning: ISO C++ forbids converting a string constant to ‘char*’ [-Wwrite-strings]

 135 | ATM atm(0,"mad123");

   |      ^~~~~~~~


LATEST TUTORIALS
APPROVED BY CLIENTS