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

A car completes its journey in three parts. It travels the first X km of its journey at an average

speed of x_Speed m/s and the next Y km at an average speed of y_Speed km/h. The car completes the

last part of its journey at an average speed of z_Speed km/h in z_Minutes minutes. Here X, x_Speed, Y,

y_Speed, z_Speed, and z_Minutes are all variables whose values you will have to take as an input from the

user. Find the average speed for its entire journey, giving your answer in km/h.


speed =

distance

time


Computers represent color by combining the sub-colors red, green, and blue (rgb). Each sub-color's value can range from 0 to 255. Thus (255, 0, 0) is bright red, (130, 0, 130) is a medium purple, (0, 0, 0) is black, (255, 255, 255) is white, and (40, 40, 40) is a dark gray. (130, 50, 130) is a faded purple, due to the (50, 50, 50) gray part. (In other words, equal amounts of red, green, blue yield gray).

Given values for red, green, and blue, remove the gray part.


Lets create your first cipher!!! Cipher is an algorithm that you can use to encrypt and decrypt

sensitive information. In an information system, sensitive information is stored in a 16-bit unsigned

number, where bit-wise information is stored in following format, 9-bits are reserved for account number

and 7-bits are reserved for customer ID.


15 14 13 12 11 10 9 8 7 6 5 4 3 2 1 0

C C C C C C C A A A A A A A A A


a) Using bit wise operators, write a function to extract customer ID

b) Another function to extract account number.

c) Due to security concerns, you have been given a task to create a cipher. Write a function to

encrypt the 16-bit number (X) using the following expression.

y = aX + b, consider a = 5 and b = 233


d) Write another function to decrypt the number and display the original number.


Write a C program to input marks of five subjects Physics, Chemistry, Biology, Mathematics and Computer, calculate percentage and grade according to given conditions:

Find and display the values of both sides of the following mathematical series expression and

an absolute difference of both sides. User can input either of angles in degree 90, 60, 30 etc.


sin(x) = x −

x

3

3!

+

x

5

5!

x

7

7!

+

x

9

9!


Once the user enters the angle in degrees. Your program should do the following (Write separate

functions for a, b, c, and d)

a) LHS Result

b) RHS Result

c) Difference

d) First term, series of two terms, series of three terms, series of four terms, series of five terms.


Machine Problem: The National Earthquake Information Center has asked you to write 

   a program implementing the following decision table 

   to characterize an earthquake based on its Richter scale number: 

   Richter Scale Number (n)    Characterization

       n < 5.0                  Little or no damage 

       5.0 <= n < 5.5           Some damage 

       5.5 <= n < 6.5           Some damage; walls may crack or fall 

       6.5 <= n < 7.5           Disaster: houses and buildings may collapse 

       higher                   Catastrophe:  Most buildings destroye




Can you share a concept of a function?

  • It can be a simple C++ code applying a user-defined function OR
  • An animated image / video doing activities; explain how this can be related to our function discussion.

Find and display the values of both sides of the following mathematical series expression and

an absolute difference of both sides. User can input either of angles in degree 90, 60, 30 etc.


sin(x) = x −

x

3

3!

+

x

5

5!

x

7

7!

+

x

9

9!


Q2: Answer the questions (i) and (iii) after going through the following class:
class Seminar
{
int time;
public:
Seminar() //Function 1
{
time = 30;
cout << "Seminar starts now" << endl;
}
void lecture() //Function 2
{
cout << "Lectures in the seminar on" << endl;
}
Seminar(int duration) //Function 3
{
time = duration;
cout << "Seminar starts now" << endl;
}
~Seminar() //Function 4
{
cout << "Thanks" << endl;
}
};
i. Write statements in C++ that would execute Function 1 and Function 3 of class Seminar.
ii. In Object Oriented Programming, what is Function 4 referred as and when does it get invoked/called?
iii. In Object Oriented Programming, which concept is illustrated by Function 1 and Function 3 together?
Q2: Answer the questions (i) to (iv) based on the following:
class Publisher
{
char pub[12];
double turnover;
protected:
void register();
public:
Publisher();
void enter();
void display();
};

class Branch
{
char city[20];
protected:
float employees;
public:
Branch();
void haveit();
void giveit();
};

class Author : private Branch, public Publisher
{
int acode;
char aname[20];
float amount;
public:
Author();
void start();
void show();
};
i. Write the names of data members, which are accessible from objects belonging to class Author.
ii. Write the names of all the member functions which are accessible from objects belonging to class Branch.
iii. Write the names of all the members which are accessible from member functions of class Author.
iv. How many bytes will be required by an object belonging to class Author?
LATEST TUTORIALS
APPROVED BY CLIENTS