by CodeChum Admin
There are different kinds of numbers, but among them all, the most commonly used numbers in our daily lives are those positive ones. So, I only want you to count all the positive numbers from the 4 outputted values and print out the result.
Go and search for the positive ones among these four!
Define a function CalcPyramidVolume with double data type parameters baseLength, baseWidth, and pyramidHeight, that returns as a double the volume of a pyramid with a rectangular base. Relevant geometry equations:
Volume = base area x height x 1/3
Base area = base length x base width.
(Watch out for integer division).
Where's the Biggest One?
by CodeChum Admin
We've already tried comparing 3 numbers to see the largest among all, so let's try a more complicated mission where we locate the position of the largest among 5 numbers. There are only 4 possible cases for this mission:
- if the largest digit is the first digit, print "Leftmost"
- if the largest digit is the third digit, print "Middle"
- if the largest digit is the last digit, print "Rightmost"
- if none of the above is correct, print "Unknown"
Now, show me how far you've understood your lessons!
Make a file by yourself named ”Integer.txt” and add 5 integer values in it. Now, write a C++
program that reads data (5 integers) from the file and store them in integer array. Also make another
integer array (int result []) of same size to store the results. The program should check for each number
in array if it is prime number or not. If the number is prime, update value in result[] array from 0 to 1.
Lastly, write output in another file named “Result.txt”
Example
Input:
Integer.txt
2 11 1 17 8
Output:
Result.txt
1 1 0 1 0
Hint: Prime number are those which is only divisible by 1 or itself.
Task 2
Write a program which takes 3 students’ data from file (“input.txt”) and displays the grade
obtained by student in new file (“output.txt”).
Hint: The program will read name from the file and then the marks obtained in three subjects.
Add those marks and convert them out of 100 and display the grade obtained by student.
Repeat these steps for three students
Score (out of
100)
Grade
0 – 49.5
F
49.5 – 57.5
D
57.5 – 71.5
C
71.5 – 84.5
B
>= 84.5
A
Task 2
Write a program which takes 3 students’ data from file (“input.txt”) and displays the grade
obtained by student in new file (“output.txt”).
Hint: The program will read name from the file and then the marks obtained in three subjects.
Add those marks and convert them out of 100 and display the grade obtained by student.
Repeat these steps for three students
Score (out of
100)
Grade
0 – 49.5
F
49.5 – 57.5
D
57.5 – 71.5
C
71.5 – 84.5
B
>= 84.5
A
Make a file by yourself named ”Integer.txt” and add 5 integer values in it. Now, write a C++
program that reads data (5 integers) from the file and store them in integer array. Also make another
integer array (int result []) of same size to store the results. The program should check for each number
in array if it is prime number or not. If the number is prime, update value in result[] array from 0 to 1.
Lastly, write output in another file named “Result.txt”
Write a programme to demonstrate Hybrid Inheritance with some real examples. Also mention the possible ways of removing ambiguity in this Inheritance.
Write a program to write 5 book records in a file. Program should also perform random access in the file, after taking input for a particular record number to read and it should also perform random record overwriting after taking input of new record and the record number to overwrite. [Attributes of book: Book_id, Book_price, Book_name, Book_author_name]
Explain situation when default constructors is mandatory to be written by user