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

#include <string>
using namespace std;
struct book
{
string title;
string author;
unsigned int year;
};
int main()
{
book bookrec;
cout << “Enter Book Title:”; getline(cin,bookrec.title);
cout << “Enter Book Author:”; getline(cin,bookrec.author);
cout << “Enter Publication Year:”; cin >> bookrec.year;
cout << “The following information has been received…\n”);
cout << “Book Title:” << bookrec.title;
cout << “Book Author:” << bookrec.author;
cout << “Year Published:” << bookrec.year << “\n”;
system(“pause”);
return 0;
}


Modify Program Sample-1 by applying a structure array in the program. The program should accept 5 records of books and displays them on the screen.
The program should also include two functions: (1) a function for entering book information; and (2) a function for displaying the records.

Simulate the fragment of codes below and trace the output. 


int *p1, *p2;

p1 = new int;

p2 = new int;

*p1 = 10;

*p2 = 20;

cout << *p1 << “ ” << *p2 << endl;

p1 = p2;

cout << *p1 << “ ” << *p2 << endl;

*p2 = 30;

cout << *p1 << “ ” << *p2 << endl;


Write a program that will prompt the user to input the following:

 

1. The number of dice to be rolled.

2. How many times the dice should be rolled?

Since the values above will vary, you must use pointer arrays and dynamically allocate memory.

The program will store the total of faces per roll and the values will be later used to plot a graph. The graph should look like the output shown below

3:

4:

5:

6:

7:

8: *

9:

10:

11:

12: *

13:

14:

15:

16:

17:

18:

 

The asterisk (*) tallies the number of times that total has occurred. 3 and 18 are the minimum and maximum totals, respectively, for rolling 3 dice.

The declaration and implementation sections of the class have been defined for you. Use it to complete your program.




Wap to create One Base class Father data member fname. And Son class derived from Father dada member sname . And GrandSon derived from Son data member gname. Use appropriate function that GrandSon will display all name by it concatenating


Wap to create One Base class Father data member fname. And Son class derived from Father dada member sname . And GrandSon derived from Son data member gname. Use appropriate function that GrandSon will display all name by it concatenating


 Wap to create Hierarchical Structure. Number class is base data member int X and two derived class Perfect & Strong. It will check corresponding whether no is perfect or Strong. But thing is one input will taken and that single input will check both.



Write a program to demonstrate the order of call of constructors and destructors in case of multiple inheritance where one or more base classes are virtual.


Write a program that takes an integer minutes and converts it to seconds.


Program call National lottery dat give the winning lottery numbers. The program must use the rand function to produce six(6) random numbers between 0 & 49 & number must not repeat. Search the winning_numbers for any 2 array elements dat give the sum of >= 80 when added together, if the numbers >= 80 are more than 1 set, consider the biggest set to be the 1 chosen for draw. If the value of the sum of the 2 values is >= 80, print the message “You have won” & if the sum of the 2 numbers is < 80, print the message “You did not win”. a custom made function called amountDeterminant(double & receives a double argument), argument will be the winning number from the sum of 2 numbers. amountDeterminant. Winning numbers are in between 80 and 83, the won amount is R17M 84 & 86, amount is R2.5M, 87 & 89, amount is R16M

-use switch condition, appropriate pointer print "address the number" & for statement or initialiser list to the numbers into arrays


Display the following Employee information using the variables.


Name

Age

Gender

Address

Contact No.

Email

Monthly Salary


LATEST TUTORIALS
APPROVED BY CLIENTS