Knowee
Questions
Features
Study Tools

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

Question

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

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

Solution

The output of the given C code will be '1'.

Here's the step by step explanation:

  1. An array 'ary' of integers is declared and initialized with the values 1, 2, 3, 4.

  2. The printf function is used to print the value of '*ary'.

  3. In C, the name of the array 'ary' is a pointer to the first element of the array. Therefore, '*ary' is equivalent to 'ary[0]'.

  4. Hence, the value '1' which is the first element of the array 'ary' will be printed.

So, the correct answer is a.1.

This problem has been solved

Similar Questions

what will be the output of the c program?

What will be the output of the following code?

What will be the output of the following C++ code?

What will be the output of the following program?

What will be the output of the following C code?#include <stdio.h>int main() {    int i;    for (i = 0; i < 5; i++);    printf("%d\n", i);    return 0;}

1/4

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.