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 myFunc();//Line 3
/*Main function*/
int main()//Line 4
{//Line 5
/*Variable "var" is declared as "int" data type and it is assigned with the value "100"*/
int var = 100; //Line 6
/*Print the value*/
cout << var << endl; //Line 7
/*Call the function "myFunc()"*/
myFunc();//Line 8
/*Display the value of variable "val" after calling the function*/
cout << var << endl; //Line 9
/*Return the value 0*/
return 0; //Line 10
}//Line 11
/* Function definition */
void myFunc()//Line 12
{//Line 13
/*Variable "var" is declared as "int" data type and it is assigned with the value "50"*/
int var = 50; //Line 14
/* Print the value of the variable "var" */
cout << var << endl; //Line 15
}//Line 16
Explanation:
The above program explains the scope of the local variable...
Want to see the full answer?
Check out a sample textbook solutionChapter 6 Solutions
Starting Out With C++: Early Objects (10th Edition)
- #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_forward#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_forwardC PROGRAM Reverse + Random Formula In the code editor, there's already an initial code that contains the function declaration of the function, computeReverseNumber(int n) and an empty main() function. For this problem, you are task to implement the computeReverseNumber function. This function will take in an integer n as its parameter. This will get the reverse of the passed integer and will then compute and return the value: result = (original_number + reverse_of_the_number) / 3 In the main() function, ask the user to input the value of n, call the function computeReverseNumber and pass the inputted value of n, and print the result in the main() with two (2) decimal places. SAMPLE: Input n: 20 Output: 7.33 Input n: 123 Output: 148.00arrow_forward
- 14. What is the value of a and b after the function call myfunction1(a,b) in the main function? void myfunction1(int a, int &b) { a+t; b++; int main() { int a=5,b=53; myfunction1(a,b): } a) a=5,b=5 b) a=5,b=6 c) a=6,b=5 d) a=6,b=6arrow_forwardC++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_forward
- #include using namespace std; || function declaration int max(int num1, int num2); int main () { // local variable declaration: int a = 100; int b = 200; int ret; I| calling a function to get max value. ret = max(a, b); cout num2) result = num1; else result = num2; return result; }arrow_forwardC++ Functions provide a means to modularize applications Write a function called "Calculate" takes two double arguments returns a double result For example, the following is a function that takes a single "double" argument and returns a "double" result double squareArea(double side){ double lArea; lArea = side * side; return lArea;}arrow_forwardAn application that uses user-defined functions has to provide function prototypes.arrow_forward
- Database System ConceptsComputer ScienceISBN:9780078022159Author:Abraham Silberschatz Professor, Henry F. Korth, S. SudarshanPublisher:McGraw-Hill EducationStarting Out with Python (4th Edition)Computer ScienceISBN:9780134444321Author:Tony GaddisPublisher:PEARSONDigital Fundamentals (11th Edition)Computer ScienceISBN:9780132737968Author:Thomas L. FloydPublisher:PEARSON
- C How to Program (8th Edition)Computer ScienceISBN:9780133976892Author:Paul J. Deitel, Harvey DeitelPublisher:PEARSONDatabase Systems: Design, Implementation, & Manag...Computer ScienceISBN:9781337627900Author:Carlos Coronel, Steven MorrisPublisher:Cengage LearningProgrammable Logic ControllersComputer ScienceISBN:9780073373843Author:Frank D. PetruzellaPublisher:McGraw-Hill Education