Question
write the function definition

call the function from main and make sure it works as required.
13. DA void function named CapLock() that takes a char reference parameter. If the parameter is a letter. the function will a
0 0
Add a comment Improve this question Transcribed image text
Answer #1

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:

For s, CapLock() = s For T, Caplock() = t For 7, CapLock() = 7 Minimum of 13.4, 10.4, 9.7 and 13.02 = 9.7

Code screenshot:

Add a comment
Know the answer?
Add Answer to:
write the function definition call the function from main and make sure it works as required....
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
  • In the space below, write a C function definition for a function named StrLower, which will...

    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...

  • This is the code I wrote for myprogramminglab It works for 8 out of 9 inputs they use and I...

    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...

    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...

    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: mileEndingPo...

    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...

    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...

    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...

    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...

    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....

    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 <<...

ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT