Cody was amazed that people could grow so old and wondered If he, a robot, would also be able to grow like that. Suddenly, he heard a sharp cry nearby, and as he tumed the comer, he saw a baby. Cody never saw a baby before, plus, he was never a baby himself so he was really surprised that something could be that young. Cody asked the baby his age and the baby replied through crying, "My age is the product of The Programmer's age and your teacher's age all of which is divided by Peter's age then added by 1 Cody quickly inputted all the ages.
For example, if the Hydra had 10 heads and he called 5 friends then they would each cut 2 heads. This presented a problem, however, if the Hydra had 11 heads then that meant one of them had to cut 3 heads.
Input the number of friends Cody has to call and the number of heads the Hydra currently has and then print the minimum number of heads each one of them has to cut.
Finally, the exam is over! i think I did quite well, but I'm not very confident with my answer for number 10. I need to verify my answer.
Hey,you! Yeah, you, what's your answer for 10? Is A,B,C,D, or E?
: Write a program to overload operators in the same program by writing suitable operator member functions for following expression:
O7= ((O1 % O2)>(O3 || O4) - (O5>O6)) [Here O1,O2,O3,O4,O5,O6 and O7 are objects of a class “overloading”, and this class is having one integer data member]
y using if-else statement write a C++ program to input marks of five subjects
Physics, Chemistry, Biology, Mathematics, and Computer. Calculate the percentage
and grade according to the following rules:
Percentage >= 90%: Grade A
Percentage >= 80%: Grade B
Percentage >= 70%: Grade C
Percentage >= 60%: Grade D
Percentage >= 40%: Grade E
Percentage < 40%: Grade F
Write a program that takes input of the number of rows and then prints the diamond for the given number of rows using loops
Sample diagram
A
BCD
EFGH
IJKLMN
OPQRS
UWX
Y
class Distance with two private data members:
feet: An integer that holds the feet.
inches: An integer that holds the inches.
Write a constructor with default parameters that initializes each data member of the class.
If inches are greater than equal to 12 then they must be appropriately converted to
corresponding feet.
.
o void setFeet(int f) and int getFeet()const
o void setInches(int i) It should ensure proper conversion to feet.
o int getInches() const
Define an operator ‘+’ that overloads the standard ‘+’ math operator and allows one
Distance object to be added to another. Distance operator+ (const Distance &obj).
Define an operator - function that overloads the standard ‘-‘ math operator and allows
subtracting one Distance object from another. Distance operator-(const Distance &obj)
Define an operator= function that overloads the = operator and assign one Distance object to another. const Distance operator=(const Distance &obj)
Develop a C++ class named Complex
Complex to hold complex numbers data. The class should support functionality to support computation of complex conjugate, magnitude, phase and to print the number in format x+i(y)
x+i(y) where x
x is real and y
y is imaginary part. Provide at least three (default, copy and set by values) constructors.
Also, overload the four basic arithmetic operators(+, -, *, /) and write code to use those implementations.
We want to create a class of Product that contains multiple private data members such as
quantity: An integer that holds a count value.
objCount: A static integer that holds that count of objects.
serialNo: An integer that holds the serial number of objects of a specific product (assume
the single object of Product class).
Define a constructor that can accept two arguments i.e., totalQuantityOfProduct and
serialNumberOfProduct; and assign it to the respective data members of the class.
Moreover, the static member be shall be initialized from the outside of the class with zero
by using scope resolution operator.
Define operator = that add the value of quantity to the left hand operand. i.e. c2=c1 (the
quantity of object c2 shall be incremented with the quantity of c1).
Define unary operator - that inverts the value of quantity for product class and should
allow the statements like c1 -= 4;
Execute the provided testCases.
class named Matrix that shall contains private data member
matrix: integer type array of size 3 by 3;
constructor that should have default parameters that can set all elements to 0. Moreover, define a function called setMatrixValues(int matrixArray[3][3]) that can assign values of matrixArray (provided to the function in argument) to the matrix array (data member of the class Matrix) of the class. Along with it, define a function called displayMatrix() that can display all values of the matrix.
class named Matrix that shall contains private data member
matrix: integer type array of size 3 by 3;
constructor that should have default parameters that can set all elements to 0. Moreover,define a function called setMatrixValues(int matrixArray[3][3]) that can assign values of matrixArray (provided to the function in argument) to the matrix array (data member of the class Matrix) of the class. Along with it, define a function called displayMatrix() that can display all values of the matrix.