Explanation of Solution
Output of the Program:
The given program has been added with comments and line number.
/* Include required variables */
#include <iostream> //Line 1
using namespace std; //Line 2
/* Function prototype */
void showVar(); //Line 3
/* Main function */
int main()//Line 4
{ //Line 5
/* Loop till "count" variable is less than "10" */
for (int count = 0; count < 10; count++) //Line 6
/*Call the function "showVar()"*/
showVar(); //Line 7
/*Return the value 0*/
return 0; //Line 8
}//Line 9
/*Function definition*/
void showVar() //Line 10
{//Line 11
/* Variable "var" is declared as static "int" and assign "10" to it */
static int var = 10; //Line 12
/*Print the value "var"*/
cout << var << endl; //Line 13
/*Increment the variable "var"*/
var++; //Line 14
} //Line 15
Explanation:
The above program explains the scope of the local variable when it is declared as “static”.
“main()” function:
- In line 6, it uses the “for” loop for iterating the “count” variable equals to less than 10.
- When the value of “count” is “0”, the function “showVar()” has been called, which prints the value 10.
- When the value of “count” is “1”, the function “showVar()” has been called, which prints the value 11.
- When the value of “count” is “2”, the function “showVar()” has been called, which prints the value 12...
Trending nowThis is a popular solution!
Chapter 6 Solutions
Starting Out With C++: Early Objects (10th Edition)
- #include<stdio.h> //Standard library math.h for Mathematics functions #include<math.h> //function declaration void function1(void); void function2(void); int main(void) { //calling both function function1(); function2(); printf("\nMain function for Ceil value: %f",ceil(4.5)); return0; } // Defining the first function void function1(void) { printf("\nFirst function for Square Root: %f",sqrt(91)); } //Defining the second function void function2(void) { printf("\nSecond function for Power: %f",pow(2,4)); } I need to do what the picture is asking for.arrow_forwardClasswork Requirements: Developa program in C++ that: Reads as many test scores as the user wants from the keyboard (assuming at most 50scores). Test scores should be whole numbers. You must validate user input; only positive numbers are valid. Prints the scores in original order sorted from high to low the highest score the lowest score the average of the scores Implement the following functions using the given function prototypes: void displayArray(int array[], int size)- Displays the content of the array void selectionSort(int array[], int size)- sorts the array using the selection sort algorithm in descending Hint: refer to example 8-5 in the textbook. int findMax(int array[], int size)- finds and returns the highest element of the array int findMin(int array[], int size)- finds and returns the lowest element of the array double findAvg(int array[], int size)- finds and returns the average of the elements of the arrayarrow_forwardDescribe the performance considerations when heavily utilizing function objects.arrow_forward
- In what scenarios would it be beneficial to utilize a function object over a standard function?arrow_forwardSet-up and implementation code for a void function MaxYou are not required to write a complete C++ program but must write and submit just your responses to the four specific function related questions below: QC1: Write the heading for a void function called Max that has three intparameters: num1, num2 and greatest. The first two parameters receive data from the caller, and greatest is used to return a value as a reference parameter. Document the data flow of the parameters with appropriate comments*. QC2: Write the function prototype for the function in QC1. QC3: Write the function definition of the function in QC1 so that it returns the greatest of the two input parameters via greatest, a reference parameter. QC4: Add comments to the function definition* you wrote in QC3 that also states its precondition and postcondition.arrow_forwardIn c++ languagearrow_forward
- The types of arguments in a function call must be consistent with the types of the corresponding parameters in the function prototype’s parameter listT/Farrow_forward#include using namespace std; void myfunction(int num2, int num1); lint main() { my function (5,2); return 0; } void myfunction(int num1, int num2) {if (num1>3) cout << "A1"; else if (num1<3) cout<<"A2"; else cout<<"A3";} O A2 O A1 O A3 A1 A2 A3arrow_forwardTrue or False : The concept of function abstraction hinders our code development by confusing us with the details of the function.arrow_forward
- in c++, "Overload of functions" Write an overloaded function that returns a value based on a set of formal parameters: . z={ x - a; x + a - barrow_forwardQues tion 1 The following program converts and print the Fahrenheit equivalents of all Celsius temperatures from 0 to 100 degrees, and the Celsius equivalents of all Fahrenheit temperatures from 32 to 212 degrees. Implement the integer functions as declared in the program: #include int celcius( int fTemp ); // function prototype int fahrenheit( int eTemp ); // function prototype int main() { int i, / loop counter Il display table of Fahrenheit equivalents of Celsius temperature printf "Fahrenheit equivalents of Celcius temperatures:In"); printf( "Celciust\tFahrenhe itln"); II display Fahrenheit equivalents of Celsius 0 to 100 for( i = 0; i<= 100; i+H) { printft "%d\t\W%d\n", i, fahrenheit( i ) ); II display table of Celsius equivalents of Fahrenheit temperature printf( "\nCelcius equivalents of Fahrenheit temperatures:\n"); printf( "FahrenheituCelcius\n"); Il display Celsius equivalents of Fahrenheit 32 to 212 for( i = 32; i<= 212; i+) { printf "%d\t\w%d\n", i, celcius( i ) ); return…arrow_forwardWhat will the following program display? #include <iostream> using namespace std;// Function prototype void showMe(int arg);int main() { int num = 0; showMe(num);return 0; } void showMe(int arg) { if (arg < 10) showMe(++arg); elsecout << arg << end1; }arrow_forward
- C++ Programming: From Problem Analysis to Program...Computer ScienceISBN:9781337102087Author:D. S. MalikPublisher:Cengage Learning