The code is in C++. All the explanation is in the code comments. Hope this helps!
Code:
#include <iostream>
using namespace std;
// function 1
void CapLock(char *c)
{
// lowercase letter
if(*c >= 'a' && *c <= 'z')
{
// change to upper case
*c = (*c - 'a') + 'A';
}
// uppercase letter
else if(*c >= 'A' && *c <= 'Z')
{
// change to lowercase
*c = (*c - 'A') + 'a';
}
// else do nothing
}
// function 2
double Minimum(double d1, double d2, double d3, double d4)
{
// compare first 2 numbers
if(d1 < d2)
{
// compare 1st and 3rd numbers
if(d1 < d3)
{
// compare 1st and 4th numbers
if(d1 < d4)
// d1 is the Minimum
return d1;
// d4 is the Minimum
return d4;
}
// compare 3rd and 4th numbers
if(d3 < d4)
// d3 is the Minimum
return d3;
// d4 is the Minimum
return d4;
}
// compare 2nd and 3rd numbers
if(d2 < d3)
{
// compare 2nd and 4th numbers
if(d2 < d4)
// d2 is the Minimum
return d2;
// d4 is the Minimum
return d4;
}
// compare 3rd and 4th numbers
if(d3 < d4)
// d3 is the Minimum
return d3;
// d4 is the Minimum
return d4;
}
int main()
{
// sample run
// for function CapLock()
char c1 = 's', c2 = 'T', c3 = '7';
cout << "For " << c1 << ", CapLock() = ";
CapLock(&c1);
cout << c1 << endl;
cout << "For " << c2 << ", CapLock() = ";
CapLock(&c2);
cout << c2 << endl;
cout << "For " << c3 << ", CapLock() = ";
CapLock(&c3);
cout << c3 << endl << endl;
// for function 2
double d1 = 13.4, d2 = 10.4, d3 = 9.7, d4 = 13.02;
cout << "Minimum of " << d1 << ", " << d2
<< ", " << d3 << " and " << d4 << " =
";
cout << Minimum(d1, d2, d3, d4) << endl;
return 0;
}
Sample run:
Code screenshot:
write the function definition call the function from main and make sure it works as required....
In the space below, write a C function definition for a function named StrLower, which will receive one parameter, a pointer to a null-terminated string (i.e., pointer to char), convert each character in the string to lowercase (using the tolower function from <ctype.h>), and return nothing to the caller. Inside the function definition, you may use a for loop or a while loop. If you use any variables other than the incoming parameter, you must define them locally in the...
Write a full class definition for a class named GasTank , and containing the following members:A data member named amount of type double.A constructor that no parameters. The constructor initializes the data member amount to 0.A function named addGas that accepts a parameter of type double . The value of the amount instance variable is increased by the value of the parameter.A function named useGas that accepts a parameter of type double . The value of the amount data member...
What is wrong with the following function definition? void fill(const int a[], int size) { for (int i = 0; i < size; i++) { a[i] = 0; } return; } Answers: The function cannot change the array parameter. The array should be passed as a call-by-reference, not call-by-value. The for loop causes an out-of-bounds indexing error. Nothing, the code works fine as is.
trouble with formatting titles :( Your friend is in charge of recording titles of books in the library they work in. Since they know you're in EECS 183, they've asked you to write a function that turns a lowercase string into Title Case format. This way, they can use the function to correctly format the titles without having to worry about capitalizing anything themselves. The function you will implement is stringToTitleCase, which takes a lowercase string str as input and...
Write the definition of a function named timeOnHighway that receives three parameters, all of type double: mileEndingPoint , mileStartingPoint , and speed . The first two parameters indicate the mile markers on an interstate at which a vehicle goes to and starts at; the third parameter indicates the speed of the vehicle in miles per hour. The function returns the number of hours it takes a vehicle to go from the starting mile marker to the ending one. The function...
Need help problem 9-13 C++ Homework please help WRITE FUNCTION PROTOTYPES for the following functions. The functions are described below on page 2. (Just write the prototypes) When necessary, use the variables declared below in maino. mm 1.) showMenu m2.) getChoice 3.) calcResult m.) showResult 5.) getInfo mm.) showName 7.) calcSquare 8.) ispositive int main { USE THESE VARIABLES, when needed, to write function prototypes (#1 - #8) double num1 = 1.5; double num2 = 2.5; char choice; double result;...
4) Write a function named remove that returns void, takes in a string& called word, and an int called i that, starting from index 0, removes every ith letter from word by modifying it in place. Include a functional main method to make sure the program works. Programming language is C++, thanks in advance
in C++ and also each function has its own main function so please do the main function as well. Previously when i asked the question the person only did the function and didn't do the main function so please help me do it. 1-1. Write a function that returns the sum of all elements in an int array. The parameters of the function are the array and the number of elements in the array. The function should return 0 if...
answer in c++ Using the table below, complete the C++ code to write the function prototype statement, and the void function header. The void function should receive three double variables: the first two by value and the last one by reference. Name the formal parameters num1, num2 and answer. The function should divide the num1 variable by the num2 variable and then store the result in the answer variable. Name the function calcQuotient. Also write an appropriate function prototype for...
CHALLENGE ACTIVITY 13.1.2: Basic function call. Complete the function definition to output the hours given minutes. Output for sample program: 3.5 1 test passed All tests passed 1 #include <iostream> 2 using namespace std; 3 4 void OutputMinutesAsHours (double origMinutes) { 5 6 /* Your solution goes here */ 7 8} 9 10 int main() { 11 double minutes; 12 13 cin >> minutes; 14 15 OutputMinutesAsHours (minutes); // Will be run with 210.0, 3600.0, and 0.0. 16 cout <<...