Knowee
Questions
Features
Study Tools

Below is an array declaration in 'C' language:int ar1[] = {2,9};int ar2[3] = {9};What will be the output of the following print statement?printf("%d,%d", ar1[1], ar2[2]);(1 Point)

Question

Below is an array declaration in 'C' language:int ar1[] = {2,9};int ar2[3] = {9};What will be the output of the following print statement?printf("%d,%d", ar1[1], ar2[2]);(1 Point)

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

Solution

The output of the given print statement will be "9,0".

Explanation:

  • The array ar1 has two elements: 2 and 9. When we access ar1[1], it refers to the second element of ar1, which is 9.
  • The array ar2 has three elements: 9, 0, and 0. When we access ar2[2], it refers to the third element of ar2, which is 0.

Therefore, the print statement will output "9,0".

Similar Questions

What is the output of the following code?#include <stdio.h>int main() {    int arr[2][2] = {{1, 2}, {3, 4}};    printf("%d\n", arr[0][2]);    return 0;}

.What will be the output of the following C code?int main() {int arr[] = {1, 2, 3, 4, 5};printf("%d", arr[3]);return 0;}*1 point1234

What is the output of the following code?int arr[] = {1, 2, 3, 4, 5};int i;for (i = 0; i < 5; i++)    arr[i] = arr[i] + 2;printf("%d\n", arr[3]);

What will be the output of the following C code? #include int main() { int ary[4] = {1, 2, 3, 4}; printf("%d\n", *ary); }a.1b.Compile time errorc.Some garbage valued.Undefined variable

What will be the output of the following C code?void main() {  int a[] = {1,2,3,4,5}, *p;  p = a;  ++*p;  printf("%d ", *p);p += 2;  printf("%d ", *p);}a.24b.22c.23d.34

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.