Knowee
Questions
Features
Study Tools

Predict the output for the given code for func(8, 2) ?int func(int a, int b){    int c;    c = a << b;    return c;}Select one:a. 16b. 8c. 4d. 32

Question

Predict the output for the given code for func(8, 2) ?int func(int a, int b){    int c;    c = a << b;    return c;}Select one:a. 16b. 8c. 4d. 32

🧐 Not the exact question you are looking for?Go ask a question

Solution

The function func(8, 2) performs a left shift operation. In this operation, the digits are moved 2 places to the left.

In binary, the number 8 is represented as 1000. When we shift it 2 places to the left, it becomes 100000, which is the binary representation of the number 32.

So, the output of func(8, 2) will be 32.

Therefore, the correct answer is d. 32.

Similar Questions

Predict the output of the following code snippetint func(int arr[], int size) {        float val = 0;        int i ;        for(i = 0; i < size; i++)            val += arr[i];        val /= size;       if (val % 1 == 0)            return 1;        else            return 0;      }What will be the output for func(arr, 4) where arr = {2, 4, 8, 10 }  ?

Predict the output of the following C Programming Snippet:#include <stdio.h>int main() {  int a = 8, b = 6;  printf("%d %d", a & b, a | b);  return 0;}

What will be the output of the following pseudo code a=3, b=2?1. 2. Integer funn (Interger a, Integer b)3. if(b<4 && a<4)4. b=b+35. b=(a+c)+b6. return funn (a+1,b) + funn(b, a)-a7. End if8. return a+b -1

Predict the output of the following code snippet.123456789#include <stdio.h>int main() { int x = 5, y = 3; int *ptr1 = &x, *ptr2 = &y; int a = *ptr1 * *ptr2; printf("%d\n", x); return 0;}

What will be the output of the following code?#include<iostream>using namespace std;void func(int a, int b) { cout << (a + b);}int main() { int a = 7; func(a, 12);}Options: Pick one correct answer from below12151929

1/3

Upgrade your grade with Knowee

Get personalized homework help. Review tough concepts in more detail, or go deeper into your topic by exploring other relevant questions.