Question

QUESTION 9 What will be the output of following code snippet? int a[3] = {1, 2,...

QUESTION 9

  1. What will be the output of following code snippet?

    int a[3] = {1, 2, 3};

            int *p = a;

            int **r = &p;

            printf("%p %p", *r, a);

    A.

    Different memory addresses printed

    B.

    1 2

    C.

    Same memory address printed twice

    D.

    1 1

2 points   

QUESTION 10

  1. What will be the output of following code snippet?

    int arr[4] = {1, 2, 3, 4};

            int *p;

            p = arr + 3;

            *p = 5;

            printf("%d\n", arr[3]);

    A.

    5

    B.

    4

    C.

    3

    D.

    Compile-time Error

2 points   

QUESTION 11

  1. Which of the following statements is correct about the following code snippet?

    int i = 5;

    int *j = &i;

    A.

    j and i are pointers to an int.

    B.

    i is a pointer to an int and stores the address of j.

    C.

    j is a pointer to an int and stores the address of i.

    D.

    j is a pointer to a pointer to an int and stores address of i.

2 points   

QUESTION 12

  1. What will be the output of following program?

    #include<stdio.h>

    void change(int*, int);

    int main()

    {

        int i, arr[] = {2, 4, 6, 8, 10};

        change(arr, 5);

        for(i=0; i<=4; i++)

              printf("%d, ", arr[i]);

        return 0;

    }

    void change(int *b, int n)

    {

    int i;

          for(i=0; i<n; i++)

    *(b+1) = *(b+i)+5;

    }

    A.

    7, 9, 11, 13, 15,

    B.

    2, 4, 6. 8. 10,

    C.

    5, 5, 5, 5, 5,

    D.

    2, 15, 6, 8, 10,

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

ANSWER:-

QUESTION (9):-

OPTION (C)  Same memory address printed twice

QUESTION (10):-

OPTION (A) 5

QUESTION (11):-

OPTION (C) j is a pointer to an int and stores the address of i.

QUESTION (12):-

OPTION (D)  2, 15, 6, 8, 10,

Add a comment
Know the answer?
Add Answer to:
QUESTION 9 What will be the output of following code snippet? int a[3] = {1, 2,...
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 10 What will be the output of following code snippet? char *str; str = "%s";...

    QUESTION 10 What will be the output of following code snippet? char *str; str = "%s"; printf(str, "S"); A. S B. Garbage Value C. Compile-time Error D. Run-time Error 4 points    QUESTION 11 What will be the output of the following statements assuming that the array begins at the memory address location 7002 and size of an integer is 4 bytes? int a[3][4] = { 1, 2, 3, 4,                     5, 6, 7, 8,                     9, 10, 11, 12 }; printf("%d,...

  • 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...

  • What is the output of the following code snippet? (If there is some kind of syntax...

    What is the output of the following code snippet? (If there is some kind of syntax error indicate this by marking "error" in your answer choice) 1.        int laps = 8;        if (laps++ > --laps)               laps += 2;        else if (--laps > (laps - 1))               laps += 4;        else if (++laps)               laps -= 3;        cout << laps << endl; 2. What is the output of the following code snippet?     int j = 47;     int i = 8;     j =...

  • 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...

  • 1. Select all that are true for the following code. #include <stdio.h> #include <stdlib.h> void range(int...

    1. Select all that are true for the following code. #include <stdio.h> #include <stdlib.h> void range(int start, int end, int *results) { int length = end - start; results = malloc(sizeof(int) * length); for (int i=start; i<end; i++) { *results = i; results++; } } void printArray(int *arr, int length) { for (int i=0; i<length; i++) { printf("%d ", arr[i]); } } int main() { int *x; int s = 2; int e = 11; range(s, e, x); printArray(x, e...

  • 51. What is the output of the following code snippet? int number = 0; int ptr_num...

    51. What is the output of the following code snippet? int number = 0; int ptr_num -&number ptr_num 60; number-80 cout < "ptr num << endl b, 60 c. 80 d. the address of number Answer 52. What is the output of the following code snippet? double num-0.0; double* ptr = &num; num = 15.0; ptr ptr 15.0 cout << num <<"ptr <<endl; a. 15 15 b. 15 30 С. 30 15 d. 30 30 Answer: 53. What is the...

  • c++ questions need help QUESTION 1 Given the following code, what is the value of *ptr?...

    c++ questions need help QUESTION 1 Given the following code, what is the value of *ptr? int var = 5; int *ptr = &var; int *myptr = ptr; *ptr = -8; var = 0; *myptr = 2; a. 2 b. -8 c. 5 d. 0 QUESTION 2 Given the following code, what is the value of ptr+1? int arr[3] = {0, 0, 0}; int *ptr = arr; *ptr = 8; a. 9 b. undefined c. the address of arr[0] d....

  • 1. Given this snippet of codes, what is the expected output? void func(int *x, int y)...

    1. Given this snippet of codes, what is the expected output? void func(int *x, int y) {     *x = *x + y;     y = 2; } void main() {     int x = 10, y = 10;     func(&x, y);     printf("x: %d, y: %d", x, y); } x= ? y=? 2. Given this snippet of codes, what is the expected output? void func(int *x, int y) {     *x = *x + y;     x = 10;...

  • Please, explain clearly each line of code with your answers. Question 1 Consider the following code...

    Please, explain clearly each line of code with your answers. Question 1 Consider the following code snippet: int ctr = 0; int myarray[3]; for (int i = 0; i < 3; i++) { myarray[i] = ctr; ctr = ctr + i; } cout << myarray[2]; What is the output of the code snippet? Question 2 Consider the following code snippet: int cnt = 0; int numarray[2][3]; for (int i = 0; i < 3; i++) {   for (int j =...

  • 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/

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