What output would be produced by the program segment

Assignment Help C/C++ Programming
Reference no: EM13165469

What output would be produced by the following program segment?

................

void fn(int &, double &); // function prototype (pass-by-reference)

void fn(int, int); // function prototype (pass-by-value)

int main()

{

int integer1 = 4, integer2 = 3;

   double sum = 1.5;

   fn(integer1, integer2);

   cout << "integer1=" << integer1 << ", integer2="

        << integer2 << ", sum=" << sum << endl;

       fn(integer1, sum);

   cout << "integer1=" << integer1 << ", integer2="

        << integer2 << ", sum=" << sum << endl;

   return 0;

}

void fn(int &x, double &y)

{

     x -= 2;

     y = x*y;

     cout << "y=" << y << endl;

     }

void fn(int x, int y)

{

     x -= 3;

     y = x*y;

     cout << "y=" << y << endl;

     }

 

10    What output would be produced by the following lines?

.....

void fn();

int main()

{

   cout << "First call to function:\n";

   fn();

   cout << "\n\nSecond call to function:\n";

   fn();

   cout << endl;

   return 0;

}

void fn()

{

   static int array1[3] = {2, 1, 3};

   cout << "\nValues on entering fn:\n";

   for (int i=0; i<3; i++)

     cout << "array1[" << i << "] = " << array1[i] << " ";

   cout << "\nValues on exiting fn:\n";

   for (int i=0; i<3; i++)

     cout << "array1[" << i << "] = "

           << (array1[i] += 2) << " ";

     }

 

 

Reference no: EM13165469

Questions Cloud

The techniques in discovering the requirements : What are some of the techniques in discovering the requirements (fact finding) for a system?
Person class that includes fields for last name : Create a Person class that includes fields for last name, first name, and zip code. Include a default constructor that initializes last name, first name, and zip code to "X" if no arguments are supplied. Also include a display function. Write a ma..
Find a regular expression and an finite automata : For the following pair of regular languages, find a regular expression and an Finite Automata that each define L1 ? L2
Discuss how your organization might use the findings : The purpose of the study defines what the researcher wants to find out and is found in the introductory section of the research article. Sometimes the purpose contains a research questions.
What output would be produced by the program segment : What output would be produced by the following program segment?
How much limestone in kg is need to completely : How much limestone in kg is need to completely neutralize a lake containing -- of H2 per liter? 5.0 * 10-3g SO4 5.2 * 10^9-L.
What is the concentration of in mass percent : What is the concentration of in mass percent? An aqueous solution has a vapor pressure of 81.9 at 50 . The vapor pressure of pure water at this temperature is 92.6.
Carlos gomez is the receiving supervisor : Carlos Gomez is the receiving supervisor for a large grocery store. Trucks arrive to the loading dock at an average rate of four per hour, according to a Poison distribution, for 8 hours each day
Introductory portion of the research article : Discuss how your organization might or might not use the findings from these studies. Substantiate your opinion with concrete examples.

Reviews

Write a Review

C/C++ Programming Questions & Answers

  Problems on oops

Problems on OOPS

  Write a program to find out all 3-digit

Write a program to find out all 3-digit Narcissistic number. A number n is a 3-digit Narcissistic number if: (a) 100   n   999, (b) The sum of its own digits each raised to the power of 3 equals to itself. For example: 153 is a Narcissistic number ..

  Attribute information about an array of floating point

Write a program that contains a main function and three other functions that will return various attribute information about an array of floating point

  Object oriented programming paradigm is better choice

Explain why object oriented programming paradigm is considered better choice than structured programming paradigm. Does it reflect our "natural" way of thinking or do you find it artificial?

  Calculates the student * averages and quiz averages based

Calculates the student * averages and quiz averages based upon input from the user. Modify this program to read in the following grade text file, * with a maximum number of students set to 35 and having five quiz scores for each student. The output s..

  Construct vector and linked lists data structures

You will prepare sorted versions of the Linked Lists and Vector data structures developed in class

  Program to tell you how many months it will take to pay off

write a program to tell you how many months it will take to pay off any loan, as well as the total amount of interest paid over the life of the loan.

  A palindrome is a number

A palindrome is a number or text phrase that reads the same backward as forward. For example, each of the following five-digit integers is a palindrome: 12321, 55555, 34543 and 11611. Write a program that reads in a five-digit integer and determines ..

  Write song playlist class-object-oriented design principles

Write a song playlist class in C++ called "PlayList" using object-oriented design principles. The playlist should support the following ADT.The implementation should be based on an array of strings to store the song titles.

  Create program that uses functions and reference parameters

Create program that uses functions and reference parameters, and asks user for the outside temperature.

  Write a function named largest which will receive the array

Write a function named largest which will receive the array as input and return the variable LargestNumber.

  C programme to find the minimum and maximum value

write a c programme to find the minimum and maximum value each elements in each row ,to create table b,having 5 rows and 2 coloums,the first coloum of table b is the maximumvalue and thye second coloum is the maximum value in each row.

Free Assignment Quote

Assured A++ Grade

Get guaranteed satisfaction & time on delivery in every assignment order you paid with us! We ensure premium quality solution document along with free turntin report!

All rights reserved! Copyrights ©2019-2020 ExpertsMind IT Educational Pvt Ltd