Follow Our FB Page << CircleMedia.in >> for Daily Laughter. We Post Funny, Viral, Comedy Videos, Memes, Vines...

What is the output for the following program

main()

{

int arr2D;

printf("%d\n", ((arr2D==* arr2D)&&(* arr2D ==
arr2D)) );

}

What is the output for the following program main() { ..

Answer / susie

Answer :

1

Explanation

This is due to the close relation between the arrays and
pointers. N dimensional arrays are made up of (N-1)
dimensional arrays.

arr2D is made up of a 3 single arrays that contains 3
integers each .

The name arr2D refers to the beginning of all the 3 arrays.
*arr2D refers to the start of the first 1D array (of 3
integers) that is the same address as arr2D. So the
expression (arr2D == *arr2D) is true (1).

Similarly, *arr2D is nothing but *(arr2D + 0), adding a zero
doesn’t change the value/meaning. Again arr2D is the
another way of telling *(arr2D + 0). So the expression
(*(arr2D + 0) == arr2D) is true (1).

Since both parts of the expression evaluates to true the
result is true(1) and the same is printed.

 Is This Answer Correct ? 3 Yes 0 No

More C Code Interview Questions

void pascal f(int i,int j,int k) { printf(“%d %d %d”,i, j, k); } void cdecl f(int i,int j,int k) { printf(“%d %d %d”,i, j, k); } main() { int i=10; f(i++,i++,i++); printf(" %d\n",i); i=10; f(i++,i++,i++); printf(" %d",i); }

#define FALSE -1 #define TRUE 1 #define NULL 0 main() { if(NULL) puts("NULL"); else if(FALSE) puts("TRUE"); else puts("FALSE"); }

To Write a C program to remove the repeated characters in the entered expression or in entered characters(i.e) removing duplicates.

how to return a multiple value from a function?

Is the following code legal? struct a { int x; struct a b; }

#include<stdio.h> main() { struct xx { int x; struct yy { char s; struct xx *p; }; struct yy *q; }; }

Link list in reverse order.

#define DIM( array, type) sizeof(array)/sizeof(type) main() { int arr; printf(“The dimension of the array is %d”, DIM(arr, int)); }

how to create a 3x3 two dimensional array that will give you the sums on the left and bottom columns

what will be the position of the file marker? a: fseek(ptr,0,SEEK_SET); b: fseek(ptr,0,SEEK_CUR);

program to find magic aquare using array

int i,j; for(i=0;i<=10;i++) { j+=5; assert(i<5); }

Categories
• C Code (422)
• C++ Code (128)
• VC++ Code (17)
• Java Code (84)
• Dot Net Code (114)
• Visual Basic Code (11)
• Programming Code AllOther (62)