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


Explain at least not less than five differences between data-oriented programming and 

object-oriented programming. In your explanations, include concepts of data-oriented 

design, object-oriented design, and use at least five examples which should include 

source codes to support your arguments.



Type two statements that use rand() to print 2 random integers between (and including) 100 and 149. End with a newline. Ex:
101
133
Note: For this activity, using one statement may yield different output (due to the compiler calling rand() in a different order). Use two statements for this activity. Also, srand() has already been called; do not call srand() again.

#include <cstdlib> // Enables use of rand()
#include <ctime> // Enables use of time()
using namespace std;

int main() {
int seedVal;
cin >> seedVal;
srand(seedVal);

/* Your solution goes here */

return 0;
}
Define a class called Point that contains two data members: x and y of float type. Define constructors to initialize the data members. Define a friend function to calculate distance between two point objects. Declare a class DArray which has data member size to store the size of the array, and element - a pointer to point class type. Define 1-arg. constructor that takes size as parameter and allocates memory dynamically to element of given size. Also define destructor to release the memory. Overload [] operator that takes the index position as parameter to manipulate (store/retrieve) the required element in the array. In main create an object of DArray to hold 3 objects of Point type and find the distance between every pair of points.
Create a class called Person that has three private data members name, age and height and the
following public member functions:
• Default constructor – To initialize the data members
• Parameterized constructor – To initialize it to the given values
• getInput() - To get the person details from the user
• showOutput() - A constant member function to display the person details. Names
should be left justified and age and height to be right justified
isTaller() - A constant member function that takes a constant person object as parameter and
compares the height of the person object which calls this function with the height of the person
object that is passed as parameter and returns true if the calling object is taller than passed
argument; otherwise returns false; Write a main function to create an array of 3 Person objects
and find the tallest person. Display all the persons details and print the details of the tallest
person.

Write a c++ program to generate a dynamic multiplication table allow the user to specify the following;

-The type of multiplication table 

-The starting point 

-The ending point

// 2 * 2 = 1

// 2 * 10 = 10




  1. Develop a program to display the multiplication table for any numbers key in by the user, define the loop to display the multiplication process in a function.
  2. Define a function to find out the minimum, maximum, and mean values in the array of 10 numbers.

Using the code stub below, output all combinations of character variables a, b, and c, in the order shown below. If a = 'x', b = 'y', and c = 'z', then the output is: xyz xzy yxz yzx zxy zyx

Your code will be tested in three different programs, with a, b, c assigned with 'x', 'y', 'z', then with '#', '$', '%', then with '1', '2', '3’.


#include

using namespace std;


int main() {

char a;

char b;

char c;


cin >> a;

cin >> b;

cin >> c;


/* Your solution goes here */


cout << endl;


return 0;

}


1) which of the following is not a control structure used in C++?

A) Iteration

B) Decision

C) Sequence

D) Transformation


2) which of the following causes a syntax error?

A) Missing semicolon in statement in main().

B) A problem in calling function.

C) adding parameters to int main() function

D) storing a string in an integer


3) cin is

A) variable

B) built-in function

C) user-defined function

D) constructor


4) which of the following statement is correct above the array?

A) A pointer must always be initialized within functions.

B) A pointer must always be initialized outside all functions

C) A pointer must always be initialized .

D) none of the above


5) which of the following best describes polymorphism?

A) single value

B) several values

C) single form

D) multiple forms


Type two statements that use rand() to print 2 random integers between (and including) 100 and 149. End with a newline. Ex:

101

133

Note: For this activity, using one statement may yield different output (due to the compiler calling rand() in a different order). Use two statements for this activity. Also, srand() has already been called; do not call srand() again.

#include <cstdlib> // Enables use of rand()

#include <ctime>  // Enables use of time()

using namespace std;

int main() {

  int seedVal;

  cin >> seedVal;

  srand(seedVal);

  /* Your solution goes here */

  return 0;

}

Using the code stub below, type a statement using srand() to seed random number generation using variable seedVal. Then type two statements using rand() to print two random integers between (and including) 0 and 9. End with a newline. Ex:

 5

 7

Note: For this activity, using one statement may yield different output (due to the compiler calling rand() in a different order). Use two statements for this activity. Also, after calling srand() once, do not call srand() again.

#include <iostream>

#include <cstdlib> // Enables use of rand()

using namespace std;

int main() {

  int seedVal;

  cin >> seedVal;

  /* Your solution goes here */

  return 0;

}

LATEST TUTORIALS
APPROVED BY CLIENTS