Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

QUESTION 1 Which of the following Array initializations is correct and will NOT throw an error? A. int arr[2][] = {10,20,30,40}; B. int arr[][2] =

QUESTION 1

  1. Which of the following Array initializations is correct and will NOT throw an error?

    A.

    int arr[2][] = {10,20,30,40};

    B.

    int arr[][2] = {10,20,30,40};

    C.

    int arr[][] = {10,20,30,40};

    D.

    int arr = {10,20,30,40};

2 points

QUESTION 2

  1. What will be the output of following statements?

    int my_array[5] = { [2] = 7, [4] = 6 };

    for (int i = 0; i<5; i++)

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

    A.

    0 0 0 7 0 6

    B.

    0 0 7 0 6 0

    C.

    0 0 7 0 6

    D.

    0 0 0 7 6

2 points

QUESTION 3

  1. What will be the output of following statements?

    int arr[5] = {1};

    for (int i = 0; i < 5; i++)

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

    A.

    1 1 1 1 1

    B.

    1 2 3 4 5

    C.

    0 0 0 0 1

    D.

    1 0 0 0 0

2 points

QUESTION 4

  1. What will be the output of following statements?

    int arr[5] = {1};

    for (int i = 0; i < =5; i++)

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

    A.

    1 1 1 1 1

    B.

    The program may print 1 followed by 0 four times followed by garbage value, or may crash if address (arr+5) is invalid.

    C.

    0 0 0 0 1

    D.

    1 0 0 0 0

2 points

QUESTION 5

  1. What will be the output of following statements?

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

    for (int i = 0; i < 2; i++)

    for (int j = 0; j < 2; j++)

    printf("%d ", a[i][j]);

    A.

    1 2 3 4

    B.

    4 Garbage values

    C.

    Compile-time Error

    D.

    4 3 2 1

2 points

QUESTION 6

  1. What will be the output of following statements?

    int a[5] = {5, 1, 15, 20, 25};

    int i, j, m;

    i = ++a[1];

    j = a[1]++;

    m = a[i++];

    printf("%d, %d, %d", i, j, m);

    A.

    2, 1, 15

    B.

    1, 2, 5

    C.

    3, 2, 15

    D.

    2, 3, 20

2 points

QUESTION 7

  1. Given an array:

    int arr[3][2][2]={1,2,3,4,5,6,7,8,9,10,11,12};

    What will be the value of arr[2][1][0]?

    A.

    5

    B.

    7

    C.

    9

    D.

    11

2 points

QUESTION 8

  1. What will be the output of following code?

    int func(int);

    int main()

    {

    int i = 3;

    i = func(i);

    i = func(i);

    printf("%d", i);

    return 0;

    }

    int func(int i)

    {

    if(i%2)

    return 0;

    else

    return 1;

    }

    A.

    3

    B.

    1

    C.

    0

    D.

    2

2 points

QUESTION 9

  1. What will be printed for the following statement?

    printf("%d", strcmp("strcmp()", "strcmp()"));

    A.

    0

    B.

    1

    C.

    2

    D.

    -1

2 points

QUESTION 10

  1. What will be the output of following statements?

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

    printf("%d",a[a[1]]);

  1. A.

    3.000000

    B.

    5.000000

    C.

    4.000000

    D.

    6.000000

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Data Mining Concepts And Techniques

Authors: Jiawei Han, Micheline Kamber, Jian Pei

3rd Edition

0123814790, 9780123814791

More Books

Students also viewed these Databases questions

Question

Explain briefly the average cost method.

Answered: 1 week ago

Question

1. Describe a comprehensive approach to retaining employees.pg 87

Answered: 1 week ago