Question

Question 6 (1 point) Consider the following piece of code. What will the output be of this code? int foo() { int fun = 0; intprint (foo ()); -1 2 1 0

0 0
Add a comment Improve this question Transcribed image text
Answer #1

int foo(){
    int fun = 0 ;
    int bar(int fun){
        fun = fun - 1 ;
        return fun-1 ;
   }
    return fun + bar(fun + 1) ;
}
print(foo())

output of code = -1 (option-a)

Add a comment
Know the answer?
Add Answer to:
Question 6 (1 point) Consider the following piece of code. What will the output be of...
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
  • QUESTION 6 What is the output of following C code? struct numbers     {         int x...

    QUESTION 6 What is the output of following C code? struct numbers     {         int x = 2;         int y = 3;     } int main() {   struct numbers nums;         nums.x = 110;         nums.y = 100;         printf("%d\n%d", nums.x, nums.y);         return 0; } A. Compile-time Error B. 110 100 C. 2 3 D. Run-time Error 2 points    QUESTION 7 What is the output of following C code? typedef struct student {         char *stud; }s1; int main() {   s1 s;         s.stud...

  • Consider the following piece of code int adjust = 0; int foo(int factor, function qux) {...

    Consider the following piece of code int adjust = 0; int foo(int factor, function qux) { int offset = bar(factor) + adjust adjust = (qux (offset) + adjust) / 2; return offset; } Which of the names (symbols) are bound at run-time? factor, qux, and offset foo, factor, and qux All the symbols. adjust, factor and offset

  • Question 6 (1 point) What is the output of the following code snippet? Please ensure your...

    Question 6 (1 point) What is the output of the following code snippet? Please ensure your answe. spaced according to the program code output. public static void main(String[] args) int channel = assignChannel (2); System.out.println("Channel: " + channel); ) public static int assignChannel(int channel) return channel + 3; > A/

  • Give the output for the following code assume int globalvar 10: above the function prototypes void...

    Give the output for the following code assume int globalvar 10: above the function prototypes void foo(int&); void bar(int); int main() { int globalVar = 5; foo(globalVar); cout << globalVar << endl; bar(globalVar); cout << globalVar << endl; return 0; } void foo(int& x) { x = globalVar + x; cout << globalVar << endl; return; void bar(int x) { globalVar + x; cout << globalVar << endl; X = return;

  • Problem 4 (25 points). What will the following code print? Why? Identify the line where the...

    Problem 4 (25 points). What will the following code print? Why? Identify the line where the vulnerability is. Explain the vulnerability. Show how the vulnerability can be eliminated Algorithm 2 Example vulnerability l.void called (int foo) 2. if (foo 1) printf("foo") 3. else printf("bar" S.int main O 6. called(2): 7. return 0:)

  • Suppose you were debugging the push() function of your program. Which of the following variables would...

    Suppose you were debugging the push() function of your program. Which of the following variables would be accessible to the debugger before the function is called? static struct node *stack; static struct node *new_node() { int size = sizeof(struct node); return malloc(size); void push(void *value) { struct node *n = new_node(); n->value = value; n->next = stack; stack = n; return malloc(size); void push (void *value) { struct node *n = new_node(); n->value = value; n->next = stack; stack =...

  • Consider the following small program. What will the output be? def foo(x): print(x) def bar(): return...

    Consider the following small program. What will the output be? def foo(x): print(x) def bar(): return 3 def baz(y, z): return y * z a = bar() + 2 b = baz(a, 2) foo(a + b) 10 3 2 25 none of these 15

  • D Question 3 For the following question, assume that int[] = {6, 2, 4, 5, 2,...

    D Question 3 For the following question, assume that int[] = {6, 2, 4, 5, 2, 1, 6, 2, 5) and consider the recursive method foo" public int foo(int[], int b, int 1) { if ( < length) { if (*[3] !- b) return foo(a, b, +1); else return foo(a, b, 3+1) + 1; }else return ; What is the result of calling foo(a, 3,0);? 0 1 02 3 00

  • Question 23 (1 point) What is the output of the following code snippet? int[] myarray =...

    Question 23 (1 point) What is the output of the following code snippet? int[] myarray = {62, 33, 5, 27, 41, 8, 39, 9); System.out.println(myarray[2]); System.out.println(myarray[6]); Blank # 1 Blank # 2 A/

  • QUESTION 1 What is the output of the following code snippet? int main() { bool attendance...

    QUESTION 1 What is the output of the following code snippet? int main() { bool attendance = false; string str = "Unknown"; attendance = !(attendance); if (!attendance) { str = "False"; } if (attendance) { attendance = false; } if (attendance) { str = "True"; } else { str = "Maybe"; } cout << str << endl; return 0; } False True Unknown Maybe QUESTION 2 What is the output of the following code snippet? #include <iostream> #include <string> using...

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