Int's are not the only data type that can be passed to a function. All valid data types, such as double, char, bool, string, etc. can be passed.
Ask the user to enter their first name and last name in main(). Pass those values to a function and produce the last two lines of output shown below:
Output:
Enter your first name: [user types: Mary Jo]
Enter your last name: [user types: De Arazoza]
Your full name is: Mary Jo De Arazoza
Your name can also be written as: De Arazoza, Mary Jo
This is a twist on the previous exercise that will help you review loops and decision structures. You will again ask the user to enter two numbers. However, you will ALWAYS subtract the smaller number from the larger number to ensure that you never get a negative number for an answer. You do this by checking the numbers and switching them if they are not in the right order (larger then smaller). All of this checking, switching, subtracting, and output of the answer should occur in a function.
Finally, ask the user if they would like to run the program again. By now, you should know exactly what type of loop to use.
Output:
Enter two integers (separated by a space) and this program will subtract the smaller from the larger: [user enters: 7 5]
7 - 5 = 2
Do you want to run this program again? [user enters: y]
Enter two integers (separated by a space) and this program will subtract the smaller from the larger: [user enters: 5 7]
7 - 5 = 2
Do you want to run this program again? [user enters: n]
This is another easy exercise to test your knowledge of the fundamentals. In main(), ask the user to enter two integers. Pass those two integers to a function that will subtract one number from another. This function must also output the answer to the user.
Output:
Enter two integers (separated by a space) and this program will subtract them: [user enters: 5 7]
5 - 7 = -2
Create two functions (with appropriate names) that produce the output below. Both functions must use a prototype. All that should be present in main() is the call to these two functions and a blank line of output between the function calls.
This is a very easy exercise. Focus on the fundamentals. Make sure you review my solution file to make sure your syntax and name choice is good.
Output:
This is the first part of my program.
It was created with a function. <-- These two lines are output by the first function
This is the second part of my program.
It was created with a different function. <-- These two lines are output by the second function
The program will need to calculate the final mark and corresponding grade and letter
grade based on the information given below.
• The final mark is derived from the following components of the assessments.
• Result calculation is based on information below:
o Exam (50%)
o Coursework (50%) components are made up of the total from the mid term test
(20%), programming assignment (15%) and lab practice (15%).
▪ Courseworks = Mid term test * 0.20 + Lab Practices (total marks /
150) * 0.15 + Programming Assignment * 0.15
▪ Final Mark = Exam * 0.5 + Courseworks
• Your program should also display the letter and letter grade based on the table
below:
Table A: Grade
MARKS
GRADE
Letter
Grade
Percentage
75 to 100
Distinction
A
80 - 100
A-
75 - 79Page 4
60 to 74
Credit
B+
70 - 74
B
65 - 69
B-
60 - 64
50 to 59
Pass
C+
55 - 59
C
50 - 54
0 to 49
Fail
C-
45 - 49
D
40 - 44
F
0 - 39
Write a program to find sum and average of three values using override method and overload method.
Suppose we have an Array1 [5,3,8,15,12]. a) Function called Insert to add value at the beginning of Array. Now Array1 look like(if we insert 1 in beginning): [1,5,3,8,15,12]. b) Function called Insert to add value at the last of Array. Now Array1 look like(if we insert 17 in end): [5,3,8,15,12,17]. c) Function called remove to remove new value after specific value in list. Array1 is [5,3,8,15,12], if we remove 3 then it is [5,8,15,12]. d) Function called Display to show all values of Array1 [5,3,8,15,12]
#include <iostream> using namespace std; #include <string>
class cat
string color="White": string action="sitting"
Your Code Here
int main()
cat cl;
cat c2("Black"):
cat c3("Brown", "jumping");
cat c4("Red", "purring");
cl.print_cat():
c2.print_cat();
c3.print_cat():
c4.print_cat():
cl.change_color("Blue"); c3.change_color("Purple");
cl.print cat();
c3.print_cat():
return 0:
Complete the cat class so the main function above produces the following output:
White cat is sitting
Black cat is sitting Brown cat is jumping
Red cat is purring
Blue cat is sitting Purple cat is jumping
Complete the cat class so the main function above produces the following output:
White cat is sitting
Black cat is sitting Brown cat is jumping
Red cat is purring
Blue cat is sitting Purple cat is jumping
1. Write a program that will illustrate the use of a function for computing the square of a number. There must be three other functions aside from main(). The First function must be responsible for inputting the data, the second for computation of squares and the third, for Displaying the result. 10 points