Question

In 5 complete sentences using your own words explain what is reference variables? Give an example...

  1. In 5 complete sentences using your own words explain what is reference variables? Give an example where passing argument by reference would be useful?

  2. Write a function named HeightInInches() that accepts two arguments - height in feet and height in inches. When the function is called, it should return a value that is height converted to inches in total. Write the function: (For example: If a person's height is 5' 5" then the function should return 65")
0 0
Add a comment Improve this question Transcribed image text
Answer #1

Answer

  • A reference variable is an alternate name for an already existing variable
  • Once a reference is initialized with a variable we can't change it
  • if we perform any changes on the reference variables than changes will be applicable on the original value
  • A reference must be initialized when it is created unlike pointers
  • if we want to return multiple values from a function than it is not possible to return in that scenario we use pass by reference so that it will modify the original value from that function

#include<iostream>
using namespace std;
int HeightInInches(int f,int i){
return f*12+i;
}

int main(){
int f,i;
cout<<"Enter heigtht feets and inches: ";
cin>>f;
cin>>i;
cout<<"Height in inches : "<<HeightInInches(f,i);
return 0;

}

Add a comment
Know the answer?
Add Answer to:
In 5 complete sentences using your own words explain what is reference variables? Give an example...
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
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