147k views
5 votes
Define a function PrintFeetInchShort, with int parameters numFeet and numInches, that prints using ' and " shorthand. End with a newline. Ex: PrintFeetInchShort(5, 8) prints: 5' 8" Hint: Use \" to print a double quote.

1 Answer

7 votes

Answer:

The solution code is written in C++

  1. #include <iostream>
  2. using namespace std;
  3. void PrintFeetInchShort(int numFeet, int numInches){
  4. cout<<numFeet<<"\'"<<numInches<<"\""<<"\\";
  5. }
  6. int main()
  7. {
  8. PrintFeetInchShort(5, 8);
  9. return 0;
  10. }

Step-by-step explanation:

Firstly, create a function PrintFeetInchShort that takes two integers, numFeet and numInches (Line 5). Display the numFeet followed by a single quote, '. To print the single quote, we can use the escape sequence, \'. (Line 6)

After the single quote, it is followed with numInches and then a double quote ". The double quote is printed using another escape sequence , \".

Finally print the new line, "\\"

User Andrew Norrie
by
4.9k points