Question
give the output of the codes in C++
int g(int x) { int tmp = x + 1; return x* tmp; int fint x, int y) { X += Y; return g(x); int main() { int x = 3; cout << g(x)
0 0
Add a comment Improve this question Transcribed image text
Answer #1

Answer:

a)
12
20
30

b)
12

c)
Enter=-6
Add a comment
Know the answer?
Add Answer to:
give the output of the codes in C++ int g(int x) { int tmp = x...
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
  • Convert the below code into if else selection: #include <iostream> using namespace std; int main() {...

    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; }

  • 41. Executing the "continue" statement from within a loop     causes control to go     A....

    41. Executing the "continue" statement from within a loop     causes control to go     A. to the next line of code     B. out of the loop     C. to the beginning of the loop          D. to check the loop condition for repeating the loop     E. none of the above      42. The 'default' statement inside a 'switch()' is optional.          T__   F__             43. The following 'switch' implementation is legal:              int i = 2;        ...

  • can you show me the details please. thank you 13. What is the output of the...

    can you show me the details please. thank you 13. What is the output of the following program? #include <iostream.h> void main() { int x; 1/ declare variable for (x = 1; x <= 5; x++) { // loop 5 times switch (x) { case 1: cout << x < // switch value of // if "x" is equal // display "X", but endl; case 2: cout << x << endl; // if "x" is equal // display "x", but...

  • #include <iostream> #include <conio.h> #include<limits> using namespace std; int main(){ char oparand, ch = 'Y'; int...

    #include <iostream> #include <conio.h> #include<limits> using namespace std; int main(){ char oparand, ch = 'Y'; int num1, num2, result; while(ch == 'Y'){ cout << "Enter first number: "; cin >> num1; while(1){//for handling invalid inputs if(cin.fail()){ cin.clear();//reseting the buffer cin.ignore(numeric_limits<streamsize>::max(),'\n');//empty the buffer cout<<"You have entered wrong input"<<endl; cout << "Enter first number: "; cin >> num1; } if(!cin.fail()) break; } cout << "Enter second number: "; cin >> num2; while(1){ if(cin.fail()){ cin.clear(); cin.ignore(numeric_limits<streamsize>::max(),'\n'); cout<<"You have entered wrong input"<<endl; cout <<...

  • C++ What output does the following program produce? int getValue(int a, int b, int n); int...

    C++ What output does the following program produce? int getValue(int a, int b, int n); int main() cout << getValue(1, 7, 7) << endl; return 0; } // end main int getValue(int a, int b, int n) int returnValue = 0; cout << "Enter: a = " < a << " b = " << b << endl; int c = (a + b)/2; if (C* C <= n) return value = c; else returnValue = getValue(a, C-1, n); cout...

  • what is the output of the following code segment? C++ g. int arr[3][4]; for (int i...

    what is the output of the following code segment? C++ g. int arr[3][4]; for (int i = 0; i < 3; i++) for (int j = 0; j < 4; j++) arr[i][j] =i*4 + j; for (int i = 0; i < 3; i++) for (int j = 0; j < 4; j++) cout << arr[i][j] << " "; h. int next(int & x) { x= x + 1; return (x + 1); int main() { int y = 10;...

  • Could use some help with this, Instructions: You will need to add an input statement for...

    Could use some help with this, Instructions: You will need to add an input statement for the grade variable to this code. Also add a for loop so that you can enter more than one grade. Code the for loop so that at least 7 grades can be entered. #include <iostream> #include <string> using namespace std; void main() {      char grade;           for (int x = 0; x < 7; x++)      {            cout << "Enter a...

  • What is the output of the program? int function1( int x, int& y) { if( x...

    What is the output of the program? int function1( int x, int& y) { if( x % 2 == 0) { x = x + y;    }       y = y - x;       return x; } int main() {       int a, b, result; cin >> a >> b; result = function1(a, b); cout << "a = "<< a << ", b = " << b << endl; cout << "result = " << result << endl; } Please make comments...

  • Question 5: Consider the following C++ program. switch(x) case 1: if (x > 1) case 2:...

    Question 5: Consider the following C++ program. switch(x) case 1: if (x > 1) case 2: if (x > 3) case 3: cout<<"Epic Beats!" << endl; case 4: cout << "Chill Vibes" << endl; break; case 5: cout << "Sweet Jazz" << endl; break; default: cout << "Invalid input. Try again."; A. What is the output if x = 1? B. What is the output if x = 3? C. What is the output if x = 2? D. What...

  • Create the second part of a Rock, Paper, Scissors game. The game keeps playing as long...

    Create the second part of a Rock, Paper, Scissors game. The game keeps playing as long as the user enters 'Y'. Make this case sensitive; if they enter a lower case y the game will not continue. If the user enters in anything besides upper case Y the game will end. Your text must exactly match the examples below: Example 1 with correct input Let's play Rock, Paper, Scissors Enter 1 for rock, 2 for paper, 3 for scissors 2...

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
ADVERTISEMENT