by CodeChum Admin
I have an array of 3 numbers here with me that's already in the code editor, but I want you to add some more to this list by inputting some more numbers yourself in one line and then, print out only the even numbers from the array.
Can you do that for me?
Input
The first line contains the number of elements, n, to be added.
The next line contains the n integers separated by a space.
5
33·54·32·11·8Output
Multiple lines containing an integer.
2
54
32
8A class named Processor has
•Two attributes i.e. processName and price
•A parameterized constructor to initialize attributes with user-defined values
Class MainMemory consists of
•Two attributes i.e. size and price
•A parameterized constructor to initialize attributes with user-defined values
Class MotherBoard has
•a data member named compName of type string
•a no-argument constructor to initialize with default name intel
Design a class named Computer that includes
•A data member named proc of type Processor
•A data member named ram of type MainMemory
•A data member named mboard of type MotherBoard
•A parameterized constructor that accept two arguments of type Processor and MainMemory to initialize members of these types. Moreover, within this constructor, instantiate object of MotherBoard to initialize mboard data field.
Write a main() and create necessary objects of the classes and call the corresponding functions.
The function has the following functionality:
exp(x, y) =
| 0, x = 0,
| 1, \forall x \notequal 0 and y = 0.| xy, otherwise
As a result of the above, write a corresponding recursive C++ function, exp(x, y), computing the exponentiation function with the given specifications.
Create a class named Person, which contains
•A pure virtual function named print()
•Two data fields i.e. personName and age
A class named Patient inherits Person class, which contains
•Two data fields i.e. diseaseType and recommendedMedicine
•Overridden function print() to display all details relevant to a patient
A class named MedicarePatient inherited from class Patient, which holds
•A data field representing the name of the hospital
•A data filed representing the name of the ward
•A data field representing room number
•Overridden function print() to display all details relevant to a patient
In the main function, create instances of derived classes to access respective print() function using dynamic binding.
a program to calculate the factorial value of the inputted number. Use the increment formula ( i++ ) for your solution . Apply the three looping statements for your solutions:
Sample input/output dialogue:
Enter a number: 5
Factorial value: 120
(The computation is: 1*2*3*4*5=24)
1st Solution – using for loop statement
2nd Solution – using while loop statement
3rd Solution- using do while loop statement
by CodeChum Admin
We've already made listing an array the easy way, but how about listing and printing the array in reverse order?
Make a program that will input an integer and then using loops, add items on an array/list one by one for the same number of times as that of the first inputted integer. Then, print out the array/list in ascending order. After doing that, print the array again on the next line in reverse order, that is, starting from the last item on the array/list down to the first one, each in separated lines.
Input
The first line contains the size of the array.
The next lines contains the items of the array (integers).
5
1
64
32
2
11Output
The first line contains the elements of the array printed in ascending order.
The second line contains the elements of the array printed in reversed order.
1·64·32·2·11
11·2·32·64·1by CodeChum Admin
Make a program that will accept an integer and loop for the same number of times as that of the inputted integer and input random integers and add it to the array/list one by one, per line. Afterwards, make your program accept another random integer.
Using that final integer, compare from your array/list if the final integer's value is also present in your current array/list. If so, print "Present"; otherwise, print "None".
Start coding now!
Input
The first line contains the size of the array.
The next lines contain the integers.
The last line contains an integer to be searched.
5
3
21
2
5
23
2Output
A line containing a string.
Presentby CodeChum Admin
I have an array of 3 numbers here with me that's already in the code editor, but I want you to add some more to this list by inputting some more numbers yourself in one line and then, print out only the even numbers from the array.
Can you do that for me?
Input
The first line contains the number of elements, n, to be added.
The next line contains the n integers separated by a space.
5
33·54·32·11·8Output
Multiple lines containing an integer.
2
54
32
8by CodeChum Admin
I want you to make an array of numbers for me. All you have to do is make a program that will let me input any random integer in one line. Afterwards, it will then print out all the numbers I've inputted, backwards, on separate lines.
Care to do that for me?
Input
The first line contains the size of the array.
The next line contains the integers separated by a space.
5
1·64·32·2·11Output
Multiple lines containing integers on each.
11
2
32
64
1Remember that time when we've tried identifying the largest digit among the given integer? Well, let's take it to the next level, and figure out the same thing on arrays!
Let's do this one more time!
Instructions:
IInput
The first line contains the size of the array.
The next lines contains an integer.
5
5
34
3
23
10Output
A line containing an integer.
34