write a full c++ programto find the smallest value amongst the following numbers {10,98,87,16,88,46,100} and display the results in terms of positive /index of smallest value and the smallest values itself { hint use arrays}
1. Write a program using Function Concept to Calculate Perimeter of Circle, Square, Triangle and Rectangle.
i. Function calPerimeterCircle that do not accept arguments and do not return value.
ii. Function calPerimeterSquare that do not accept arguments and return value.
iii. Function calPerimeterTriangle that accept arguments and do not return value.
iv. Function calPerimeterRectangle that accept arguments and return value
2. Please refer the following formula as guidance :
a. Perimeter of Circle = 2 π r : r = radius , use π= 22/7
b. Perimeter of Square = 4a : a = side
c. Perimeter of Triangle = a+b+c : a=side1, b=side2 and c= side3
d. Perimeter of Rectangle = 2 +(l+w) : l=length, w= width
Write a program that determines the frequency of each char in an input le. Your program
should
• read in an unknown number of chars from an input le named input.txt,
• using a function written by you, determine the frequency of occurrence of each char in
the list
• write each char followed by the frequency to the output le output.txt.
• The chars should appear in the output le in the same order as they rst appeared in
the input le.
First draw a
ow chart and then attempt the code.
Example 1
Example input and output les can be seen in Listings 9 and 10.
Listing 9: Example of input.txt
1 a
2 a
3 f
4 e
5 v
6 x
7 a
8 v
9 f
10 f
11 f
12 g
Page 4 of 5
Listing 10: Example of output.txt
1 a 3
2 f 4
3 e 1
4 v 2
5 x 1
6 g 1
Example 2
Example of additional input and output les can be seen in Listings 11 and 12.
Listing 11: Example of input.txt
1 a
2 b
3 a
4 b
5 a
6 b
7 b
Listing 12: Example of output.txt
1 a 3
2 b 4
In traditional way, there are three classes: TRUCK (number, name , NoOfWheel, Price, Capacity,
EnginePower, TypeOfConsump), BUS (number, name , NoOfWheel, Price, NoOfSeat,
EnginePower, TypeOfConsump, Color, Speed), CAR (number, name , NoOfWheel, Price,
NoOfSeat, EnginePower, TypeOfConsump, Color, Speed).
Divide the above three classes into two base classes and three derived classes. Each class will
contain two member functions, getdata() to get that class data from user and putdata() to display that
class data on the screen. How the above member data of three classes will be distributed into five
classes as shown in the following diagram.
Write the Boolean expression (in Sum of Products form) for the logic circuit that will have a 1 output when A = 0, B = 0, C = 1 and A = 1, B= 1, C= 0, and a zero (0) output for all other input states. Draw the logic diagram for this circuit.
You need to take a matrix of any size, doubles all the elements that are positive and add 10 to all
the elements that are zero or negative. Then you need to add all the elements of the array and
display the results as follows, with the total value displayed to 3 decimal places:
The sum of the matrix elements is 75.322
i. Write a function called matrixfx
Use the input matrix xin[n,m] sent by the script,
Initialise your out variable xout [n,m]
to perform the above calculations on the positive and negative numbers, depending on
the values of each element of the matrix – Tip use one logical array mask to build the
matrix xout [n,m]. No loops!
ii. Write a script called matrixAdd
Use the function matrixfx to manipulate the test data as indicated above (y).
Initialise the necessary variables to use nested loops to add up the elements of the matrix
y.
Your display should be formatted to display the final total as indicated above.
Use the aggregation (composition)
concept to define and implement the
class line(pl.x, pl.y, p2.x, p2.y) by using
two points variables P 1, and P2 of type
point2D class defined in QI. Beside the
two points Pl and P2, the line class has
the following functions: print(),
MoveRel(Dx,Dy) (use the point2D's
MoveRel(Dx,Dy) function of the two
points to achieve that), line(),
Use the point2D class as base class
to derive a new class called
Point3D(x,y,z). In addition to the
derived variables and functions
(methods) the new class has the
variable z with the functions setZ(z1),
getZ(), MoveRel(Dx,Dy,Dz), print(), and
the constructers point3D(),
point3D(x1,y1,z1,pColor), the destructor
-point3D(). Determine which function
is an override function and which one
is an overloaded function of the base
class.
Define the class point2D(x,y) for
the x, y coordinates. The class has x, y
and color as member variables and as
member function has setXY(x1,y1),
setColor(pColor), MoveRel(Dx,Dy),
getX(), getY(), getColor(pColor), Print(),
the constructers point2D(),
point2D(x1,y1,pColor), the destructor
-point2D(). The MoveRel(Dx, Dy)
function changed the x, y coordinates
by the amount of Dx, and Dy,
respectively (ex: x=x+Dx, y=Y+Dy).
Determine which function is accessor
and which one is mutator.
Input1:
google.com
Output1:
{'g': 2, 'o': 3, 'l': 1, 'e': 1, 'c' : 1, 'm' : 1}
Input2:
Netflix.com
Output2:
{'N': 1, 'e':1, 't': 1, 'f':1, 'l': 1, 'i': 1, 'x':1, '.': 1, 'c': 1, 'o': 1, 'm':1}