#include <iostream> using namespace std; - // Guess the output for the below program. // Assume...
what is the output for the following code? explain the steps. /*#include <iostream> using namespace std; int f(int &i) { i = 10; return(5 * i); } int main() { int n = 5; f(n); cout << n << "\n"; return 0; } #include <iostream> using namespace std; int sub1(int n) { n--; return n; } int main() { int m = 10; for(int j = 0; j < 10; j++) m -= sub1(j); cout << m << "\n"; return...
4) What is the output if the input istom - Sawyer? #include <iostream> using namespace std; int main() { string playerName; cout << "Enter name"; cin >> playerName; cout << endl « playerName; return 0; } a. Tom - Sawyer b. Tom Sawyer c. Tom d. Sawyer 5) Which XXX generates "Adam is 30 years old." as the output? #include <iostream> using namespace std; int main() { string name = "Adam"; int age = 30; XXX return 0; } a....
Convert the below code into if else selection: #include <iostream> using namespace std; int main() { int num; sin. >> num; switch (num) { case 1: cout << "Casel: Value is: << num << endl; break; case 2: break; case 3: cout << "Case3: Value is: " << num << endl; break; default: cout << "Default: Value is: << num << endl; break; } return; }
What is the output of this program? #include<iostream> using namespace std; int main() { int x=4, y=4, z=4; x += 2; y = z++; z = ++x + y; cout<<x<<" "<<y<<" "<<z<<endl; return 0; } Group of answer choices 4 4 4 7 4 11 7 5 12 6 5 11
Extra Credit: What is the output of the following program? (5 points) #include <iostream> using namespace std; int main ( char greetingl6]- ('H', 'e', T, T, 'o', 0'); cout <<"Greeting message: " cout< greeting << endl return 0;
Give the output of the following C++ program and explain your reasoning: #include <iostream> using namespace std; int gcd( int , int ); //Function prototype int main() { int a = 105; int b = 30; cout << “The GCD of “ << a << “ and “ << b << “ is “ << gcd(a,b) << endl; return 0; } int gcd(int a, int b) { if ( b == 0 ) return a; else return gcd(b,a%b); }
Write following program using Switch statement. #include <iostream> using namespace std; int main() int number; cout << "Enter an integer cin >> number; if (number > B) cout << You entered a positive integer: " << number << endl; else if (number (8) cout<<"You entered a negative integer: " << number << endl; cout << "You entered e." << endl; cout << "This line is always printed." return 0;
#include <iostream> #include <chrono> using namespace std; double improvedPow(double x, int y) { // To be implemented by you } int main() { cout << "To calculate x^y ..." << endl; double x; int y; cout << "Please enter x: "; cin >> x; cout << "Please enter y: "; cin >> y; if(x == 0) { if (y > 0) cout << 0 << endl; else cout << "x^y is not defined" <<endl; } else { cout << improvedPow(x,y)...
C++ output 6) What is the exact output of the following program? #include <iostream> using namespace stdi void zolo(int &a, int sb) int main int x = 5, y =8; zolo(x,y)i cout << "x " << x << endl ; cout << "y = "" << y << endl ; return o: void zolo(int &a, int &b) int v1 = b + a; ' int v2 = b-a; 3 a=v1;13
This program illustrates dynamic variables #include <iostream> using namespace std; int main () { int *p1; p1 = new int; // Variables created using the new operator are called dynamic variables cout << "Enter an integer \n"; cin >> *p1; *p1 = *p1 + 7; cout << << "Your input + 7 = " << *p1 << endl; delete p1; // Delete the dynamic variable p1 and return the memory occupied by p1 to...