Print out the cube values of the numbers ranging from 1 to 20 (inclusive). However, if the number is divisible by either 3 or 5, do not include them in printing and proceed with the next numbers. Tip: When skipping through special values, make use of the keyword continue and put them inside a conditional statement.
create two classes, first class ‘Point’ with two data
members x and y. Provide appropriate constructors, get, set or display methods.
Create the second class ‘Triangle’ with three points as its data members. Provide
appropriate constructors for this class and a display method which calls the display methods of points.
In the main function, declare three points and pass them to the constructor of an instance of the triangle class and pass direct values to the second instance of the triangle class without creating points instances. Call the display method of triangle to verify the coordinates of the triangle.
prototypes
Point():
void insertPoint(int, int):
void displayPoint(int):4. Triangle():
Triangle(Point, Point, Point):
Triangle(int, int, int, int, int, int):
void insertData():
void displayData():
NOTE: Define functions outside of the class using scope resolution operator except
constructors and destructors.
You are required to create a class for dealing with complex numbers. In this particular
example we are only applying two arithmetic operations over complex number – addition
and subtraction. In complex numbers, we treat the real and imaginary part separately. You
need to define a constant char and assign it ‘i’, indicating the imaginary part. Also declare
two variables for denoting the real part and coefficient of the imaginary part. Define the
appropriate constructors, getters, setters and destructor as per the requirements.
You are required to create an object passing 2 arguments to its constructor, another
constant object with 2 arguments to its constructor. Add them both and store the resultant
object in a third instance by using the concept of copy constructor. Following are the
function prototypes,
Complex()
Complex(int, int)
Complex add(Complex)
void display()
void display() const
You are required to create a class by the name of ‘Matrix’. The matrix private domain must
contain a 2-Dimentional array of floats. The constructor should initialize a passed value to all the locations of the array being created and if the argument is missing, it should assign 0 by default to the entire array. Define appropriate functions for inserting data into the matrix and displaying the array in a matrix form. You need to define a function by the name of ‘dot’ that would take a matrix object as an argument and would return the matrix object (temporary) to where it was called from. From where it was called, there it should assign the returned object to a new matrix class instance.
Matrix obj3=obj1.dot(obj2);
Call the display function from the new instance to see the result of two matrices multiplied.
NOTE: Define a function ’float retreive(int, int)’ where if two indices are
passed to it, it must return the value located at those locations.
Create a class by the name of ‘Product’. Create the following private members
name(String), price(Int) and quantity(Int). Define a parameter-less and a
parameterized constructor. Define the following two member functions outside the class,
void getData()
static void counter()
static int countProduct()
The class would contain a static int ‘totalProduct’, having initial value equal to zero.
Each time an instance of the product class is created, the ‘counter()’ should be called.
The ‘counter()’ increments the static member by 1 value. Suppose I create 5 products,
when I execute the following code it should display 5.
Product::totalProducts;
Create a 'Circle' class with having a static data member name 'radius' and two pointer
data members name 'circumference' and 'area' as private. Allocate memory to the
two pointers in both parameter-less and parameterized constructors - parameterized
constructor must take a single float argument for radius. Define a deep copy constructor for
the class. Note that the constructor should assign data as well as calculate 'area' and
'circumference' based on the formulae. Two other functions with return type float
must return the value 'circumference' and 'area' are holding. Get rid of the
allocated space in destructor.
Write a program in C++ to find the largest and smallest of N numbers of any data type (use function overloading). The value of N is available only at the time of execution
If the number is only divisible by 3, print "Fizz"
If the number is only divisible by 5, print "Buzz"
If the number is divisible by both 3 and 5, print "FizzBuzz"
If nothing is true in the previous conditions, skip the number
Input two integers in one line. The first inputted integer will be the starting point, and the second one shall serve as the ending point.
Use the power of loops to loop through the starting point until the ending point (inclusive), and print out each number within the range with the corresponding format shown on the sample output. However, skip the printing of statement if the integer is divisible by 4. Tip: Utilize the continue keyword to complete the process
Print out the cube values of the numbers ranging from 1 to 20 (inclusive). However, if the number is divisible by either 3 or 5, do not include them in printing and proceed with the next numbers. Tip: When skipping through special values, make use of the keyword continue and put them inside a conditional statement.