Pointers store address of variables or a memory location.

// General syntax
datatype *var_name; 

// An example pointer "ptr" that holds
// address of an integer variable or holds
// address of a memory whose value(s) can
// be accessed as integer values through "ptr"
int *ptr;  

Read More…


Pointer Basics

Question 1
What is the output of following program?
# include <stdio.h>
void fun(int x)
{
    x = 30;
}

int main()
{
  int y = 20;
  fun(y);
  printf("%d", y);
  return 0;
}
A
30
B
20
C
Compiler Error
D
Runtime Error
Pointer Basics    
Discuss it


Question 1 Explanation: 
Parameters are always passed by value in C. Therefore, in the above code, value of y is not modified using the function fun(). So how do we modify the value of a local variable of a function inside another function. Pointer is the solution to such problems. Using pointers, we can modify a local variable of a function inside another function. See the next question. Note that everything is passed by value in C. We only get the effect of pass by reference using pointers.
Question 2
Output of following program?
# include <stdio.h>
void fun(int *ptr)
{
    *ptr = 30;
}

int main()
{
  int y = 20;
  fun(&y);
  printf("%d", y);

  return 0;
}
A
20
B
30
C
Compiler Error
D
Runtime Error
Pointer Basics    
Discuss it


Question 2 Explanation: 
The function fun() expects a pointer ptr to an integer (or an address of an integer). It modifies the value at the address ptr. The dereference operator * is used to access the value at an address. In the statement ‘*ptr = 30’, value at address ptr is changed to 30. The address operator & is used to get the address of a variable of any data type. In the function call statement ‘fun(&y)’, address of y is passed so that y can be modified using its address.
Question 3
Output of following program?
#include <stdio.h>

int main()
{
    int *ptr;
    int x;

    ptr = &x;
    *ptr = 0;

    printf(" x = %d\n", x);
    printf(" *ptr = %d\n", *ptr);

    *ptr += 5;
    printf(" x  = %d\n", x);
    printf(" *ptr = %d\n", *ptr);

    (*ptr)++;
    printf(" x = %d\n", x);
    printf(" *ptr = %d\n", *ptr);

    return 0;
}
A
x = 0
*ptr = 0
x = 5
*ptr = 5
x = 6
*ptr = 6
B
x = garbage value
*ptr = 0
x = garbage value
*ptr = 5
x = garbage value
*ptr = 6
C
x = 0
*ptr = 0
x = 5
*ptr = 5
x = garbage value
*ptr = garbage value
D
x = 0
*ptr = 0
x = 0
*ptr = 0
x = 0
*ptr = 0
Pointer Basics    
Discuss it


Question 3 Explanation: 
See the comments below for explanation.
  int *ptr;  /* Note: the use of * here is not for dereferencing, 
               it is for data type int */
  int x;

  ptr = &x;   /* ptr now points to x (or ptr is equal to address of x) */
  *ptr = 0;   /* set value ate ptr to 0 or set x to zero */

  printf(" x = %d\n", x);   /* prints x =  0 */
  printf(" *ptr = %d\n", *ptr);  /* prints *ptr =  0 */


  *ptr += 5;        /* increment the value at ptr by 5 */
  printf(" x  = %d\n", x);  /* prints x = 5 */
  printf(" *ptr = %d\n", *ptr); /* prints *ptr =  5 */


  (*ptr)++;         /* increment the value at ptr by 1 */
  printf(" x  = %d\n", x);  /* prints x = 6 */
  printf(" *ptr = %d\n", *ptr);  /* prints *ptr =  6 */
Question 4
Consider a compiler where int takes 4 bytes, char takes 1 byte and pointer takes 4 bytes.
#include <stdio.h>

int main()
{
    int arri[] = {1, 2 ,3};
    int *ptri = arri;

    char arrc[] = {1, 2 ,3};
    char *ptrc = arrc;

    printf("sizeof arri[] = %d ", sizeof(arri));
    printf("sizeof ptri = %d ", sizeof(ptri));

    printf("sizeof arrc[] = %d ", sizeof(arrc));
    printf("sizeof ptrc = %d ", sizeof(ptrc));

    return 0;
}
A
sizeof arri[] = 3 sizeof ptri = 4 sizeof arrc[] = 3 sizeof ptrc = 4
B
sizeof arri[] = 12 sizeof ptri = 4 sizeof arrc[] = 3 sizeof ptrc = 1
C
sizeof arri[] = 3 sizeof ptri = 4 sizeof arrc[] = 3 sizeof ptrc = 1
D
sizeof arri[] = 12 sizeof ptri = 4 sizeof arrc[] = 3 sizeof ptrc = 4
Pointer Basics    
Discuss it


Question 4 Explanation: 
Size of an array is number of elements multiplied by the type of element, that is why we get sizeof arri as 12 and sizeof arrc as 3. Size of a pointer is fixed for a compiler. All pointer types take same number of bytes for a compiler. That is why we get 4 for both ptri and ptrc.
Question 5
Assume that float takes 4 bytes, predict the output of following program.
#include <stdio.h>

int main()
{
    float arr[5] = {12.5, 10.0, 13.5, 90.5, 0.5};
    float *ptr1 = &arr[0];
    float *ptr2 = ptr1 + 3;

    printf("%f ", *ptr2);
    printf("%d", ptr2 - ptr1);

   return 0;
}
A
90.500000 3
B
90.500000 12
C
10.000000 12
D
0.500000 3
Pointer Basics    
Discuss it


Question 5 Explanation: 
When we add a value x to a pointer p, the value of the resultant expression is p + x*sizeof(*p) where sizeof(*p) means size of data type pointed by p. That is why ptr2 is incremented to point to arr[3] in the above code. Same rule applies for subtraction. Note that only integral values can be added or subtracted from a pointer. We can also subtract or compare two pointers of same type.
Question 6
#include<stdio.h>
int main()
{
    int arr[] = {10, 20, 30, 40, 50, 60};
    int *ptr1 = arr;
    int *ptr2 = arr + 5;
    printf("Number of elements between two pointer are: %d.", 
                                (ptr2 - ptr1));
    printf("Number of bytes between two pointers are: %d",  
                              (char*)ptr2 - (char*) ptr1);
    return 0;
}
Assume that an int variable takes 4 bytes and a char variable takes 1 byte
A
Number of elements between two pointer are: 5. Number of bytes between two pointers are: 20
B
Number of elements between two pointer are: 20. Number of bytes between two pointers are: 20
C
Number of elements between two pointer are: 5. Number of bytes between two pointers are: 5
D
Compiler Error
E
Runtime Error
Pointer Basics    
Discuss it


Question 6 Explanation: 
Array name gives the address of first element in array. So when we do '*ptr1 = arr;', ptr1 starts holding the address of element 10. 'arr + 5' gives the address of 6th element as arithmetic is done using pointers. So 'ptr2-ptr1' gives 5. When we do '(char *)ptr2', ptr2 is type-casted to char pointer and size of character is one byte, pointer arithmetic happens considering character pointers. So we get 5*sizeof(int)/sizeof(char) as a difference of two pointers.
Question 7
#include<stdio.h> 
int main() 
{ 
   int a; 
   char *x; 
   x = (char *) &a; 
   a = 512; 
   x[0] = 1; 
   x[1] = 2; 
   printf("%d\n",a);   
   return 0; 
}
What is the output of above program?
A
Machine dependent
B
513
C
258
D
Compiler Error
Pointer Basics    
Discuss it


Question 7 Explanation: 
Output is 513 in a little endian machine. To understand this output, let integers be stored using 16 bits. In a little endian machine, when we do x[0] = 1 and x[1] = 2, the number a is changed to 00000001 00000010 which is representation of 513 in a little endian machine.
Question 8
int main()
{
 char *ptr = "GeeksQuiz";
 printf("%c\n", *&*&*ptr);
 return 0;
}
A
Compiler Error
B
Garbage Value
C
Runtime Error
D
G
Pointer Basics    
Discuss it


Question 8 Explanation: 
The operator * is used for dereferencing and the operator & is used to get the address. These operators cancel out effect of each other when used one after another. We can apply them alternatively any no. of times. In the above code, ptr is a pointer to first character of string g. *ptr gives us g, &*ptr gives address of g, *&*ptr again g, &*&ptr address of g, and finally *&*&ptr gives ‘g’ Now try below
int main()
{
 char *ptr = "GeeksQuiz";
 printf("%s\n", *&*&ptr);
 return 0;
}
Question 9
#include<stdio.h>
void fun(int arr[])
{
  int i;
  int arr_size = sizeof(arr)/sizeof(arr[0]);
  for (i = 0; i < arr_size; i++)
      printf("%d ", arr[i]);
}

int main()
{
  int i;
  int arr[4] = {10, 20 ,30, 40};
  fun(arr);
  return 0;
} 
A
10 20 30 40
B
Machine Dependent
C
10 20
D
Northing
Pointer Basics    
Discuss it


Question 9 Explanation: 
In C, array parameters are always treated as pointers. So following two statements have the same meaning.
void fun(int arr[])
void fun(int *arr)
[] is used to make it clear that the function expects an array, it doesn’t change anything though. People use it only for readability so that the reader is clear about the intended parameter type. The bottom line is, sizeof should never be used for array parameters, a separate parameter for array size (or length) should be passed to fun(). So, in the given program, arr_size contains ration of pointer size and integer size, this ration= is compiler dependent. 1 #include void fun(int arr[], size_t arr_size) { int i; for (i = 0; i < arr_size; i++) printf("%d ", arr[i]); } int main() { int i; int arr[] = {10, 20 ,30, 40}; // Use of sizeof is fine here size_t n = sizeof(arr)/sizeof(arr[0]); fun(arr, n); return 0; } [/sourcecode] Output: 10 20 30 40
Question 10
The reason for using pointers in a Cprogram is
A
Pointers allow different functions to share and modify their local variables.
B
To pass large structures so that complete copy of the structure can be avoided.
C
Pointers enable complex “linked" data structures like linked lists and binary trees.
D
All of the above
Pointer Basics    
Discuss it


Question 10 Explanation: 
See below explanation (A) With pointers, address of variables can be passed different functions can use this address to access the variables. (B) When large structure variables passed or returned, they are copied as everything is passed and returned by value in C. This can be costly with structure containing large data. To avoid this copying of large variables, we generally use poitner for large structures so that only address is copied. (C) With pointers, we can implement “linked” data structures. Java uses reference variables to implement these data structures. Note that C doesn't support reference variables.
Question 11
#include<stdio.h> 
void f(int *p, int *q) 
{ 
  p = q; 
  *p = 2; 
} 
int i = 0, j = 1; 
int main() 
{ 
  f(&i, &j); 
  printf("%d %d \n", i, j); 
  getchar(); 
  return 0; 
}
A
2 2
B
2 1
C
0 1
D
0 2
Pointer Basics    
Discuss it


Question 11 Explanation: 
See below f() with comments for explanation.
/* p points to i and q points to j */
void f(int *p, int *q) 
{ 
  p = q;    /* p also points to j now */
 *p = 2;   /* Value of j is changed to 2 now */
}
Question 12
Consider this C code to swap two integers and these five statements after it:
void swap(int *px, int *py) 
{ 
   *px = *px - *py; 
   *py = *px + *py; 
   *px = *py - *px; 
}
S1: will generate a compilation error S2: may generate a segmentation fault at runtime depending on the arguments passed S3: correctly implements the swap procedure for all input pointers referring to integers stored in memory locations accessible to the process S4: implements the swap procedure correctly for some but not all valid input pointers S5: may add or subtract integers and pointers.
A
S1
B
S2 and S3
C
S2 and S4
D
S2 and S5
Pointer Basics    
Discuss it


Question 12 Explanation: 
S2: May generate segmentation fault if value at pointers px or py is constant or px or py points to a memory location that is invalid S4: May not work for all inputs as arithmetic overflow can occur
Question 13
int f(int x, int *py, int **ppz) 
{ 
  int y, z; 
  **ppz += 1; 
   z  = **ppz; 
  *py += 2; 
   y = *py; 
   x += 3; 
   return x + y + z; 
} 
  
void main() 
{ 
   int c, *b, **a; 
   c = 4; 
   b = &c; 
   a = &b; 
   printf("%d ", f(c, b, a)); 
   return 0;
}

A
18
B
19
C
21
D
22
Pointer Basics    
Discuss it


Question 13 Explanation: 
Let us understand this line by line
  /* below line changes value of c to 5. Note that x remains unaffected by 
    this change as x is a copy of c and address of x is different from c*/
  **ppz += 1  
  
  /* z is changed to 5*/
  z  = **ppz; 
  
  /* changes c to 7, x is not changed */
  *py += 2; 
  
   /* y is changed to 7*/
  y = *py;    
  
  /* x is incremented by 3 */
   x += 3;    
  
  /* return 7 + 7 + 5*/
  return x + y + z;
Question 14
Predict the output of following program
#include<stdio.h>
int main()
{
    int a = 12;
    void *ptr = (int *)&a;
    printf("%d", *ptr);
    getchar();
    return 0;
}
A
12
B
Compiler Error
C
Runt Time Error
D
0
Pointer Basics    
Discuss it


Question 14 Explanation: 
There is compiler error in line "printf("%d", *ptr);". void * type pointers cannot be de-referenced. We must type cast them before de-referencing. The following program works fine and prints 12.
#include<stdio.h>

int main()
{
    int a = 12;
    void *ptr = (int *)&a;
    printf("%d", *(int *)ptr);
    getchar();
    return 0;
}
Question 15
#include<stdio.h>

void swap (char *x, char *y)
{
    char *t = x;
    x = y;
    y = t;
}

int main()
{
    char *x = "geeksquiz";
    char *y = "geeksforgeeks";
    char *t;
    swap(x, y);
    printf("(%s, %s)", x, y);
    t = x;
    x = y;
    y = t;
    printf("\n(%s, %s)", x, y);
    return 0;
}
A
(geeksquiz, geeksforgeeks)
(geeksforgeeks, geeksquiz)
B
(geeksforgeeks, geeksquiz)
(geeksquiz, geeksforgeeks)
C
(geeksquiz, geeksforgeeks)
(geeksquiz, geeksforgeeks)
D
(geeksforgeeks, geeksquiz)
(geeksforgeeks, geeksquiz)
Pointer Basics    
Discuss it


Question 15 Explanation: 
Question 16
#include <stdio.h>
int main()
{
    int arr[] = {1, 2, 3, 4, 5};
    int *p = arr;
    ++*p;
    p += 2;
    printf("%d", *p);
    return 0;
}
A
2
B
3
C
4
D
Compiler Error
Pointer Basics    
Discuss it


Question 16 Explanation: 
The expression ++*p is evaluated as "++(*p)" . So it increments the value of first element of array (doesn't change the pointer p). When p += 2 is done, p is changed to point to third element of array.
Question 17
What does the following program print?
#include
void f(int *p, int *q)
{
  p = q;
 *p = 2;
}
int i = 0, j = 1;
int main()
{
  f(&i, &j);
  printf("%d %d \n", i, j);
  getchar();
  return 0;
}
A
2 2
B
2 1
C
0 1
D
0 2
Pointer Basics    GATE CS 2010    
Discuss it


Question 17 Explanation: 
See below comments for explanation.
/* p points to i and q points to j */
void f(int *p, int *q)
{
  p = q;    /* p also points to j now */
 *p = 2;   /* Value of j is changed to 2 now */
}
Question 18
#include <stdio.h>
void f(char**);
int main()
{
    char *argv[] = { "ab", "cd", "ef", "gh", "ij", "kl" };
    f(argv);
    return 0;
}
void f(char **p)
{
    char *t;
    t = (p += sizeof(int))[-1];
    printf("%s\n", t);
}
A
ab
B
cd
C
ef
D
gh
Pointer Basics    
Discuss it


Question 19
What does the following C-statement declare? [1 mark]
int ( * f) (int * ) ;
A
A function that takes an integer pointer as argument and returns an integer.
B
A function that takes an integer as argument and returns an integer pointer.
C
A pointer to a function that takes an integer pointer as argument and returns an integer.
D
A function that takes an integer pointer as argument and returns a function pointer
Pointer Basics    GATE-CS-2005    
Discuss it


Question 19 Explanation: 
The steps to read complicated declarations : 1)Convert C declaration to postfix format and read from left to right. 2)To convert expression to postfix, start from innermost parenthesis, If innermost parenthesis is not present then start from declarations name and go right first. When first ending parenthesis encounters then go left. Once the whole parenthesis is parsed then come out from parenthesis. 3)Continue until complete declaration has been parsed. At First, we convert the following given declaration into postfix:
int ( * f) (int * )
Since there is no innermost bracket, so first we take declaration name f, so print “f” and then go to the right, since there is nothing to parse, so go to the left. There is * at the left side, so print “*”.Come out of parenthesis. Hence postfix notation of given declaration can be written as follows:
f * (int * ) int
Meaning: f is a pointer to function (which takes one argument of int pointer type) returning int . Refer http://www.geeksforgeeks.org/complicated-declarations-in-c/ This solution is contributed by Nirmal Bharadwaj.
Question 20
Consider the C program shown below.
#include <stdio.h>
#define print(x) printf("%d ", x)
int x;
void Q(int z)
{
    z += x;
    print(z);
}
void P(int *y)
{
    int x = *y + 2;
    Q(x);
    *y = x - 1;
    print(x);
}
main(void)
{
    x = 5;
    P(&x);
    print(x);
}
The output of this program is
A
12 7 6
B
22 12 11
C
14 6 6
D
7 6 6
Pointer Basics    GATE-CS-2003    
Discuss it


Question 20 Explanation: 
x is global so first x becomes 5 by the first line in main(). Then main() calls P() with address of x.
// in main(void)

x = 5 // Change global x to 5
P(&x)
P() has a local variable named 'x' that hides global variable. P() theb calls Q() by passing value of local 'x'.
// In P(int *y)

int x = *y + 2; // Local x = 7
Q(x);
In Q(int z), z uses x which is global
// In Q(int z)

z += x; // z becomes 5 + 7 
printz(); // prints 12
After end of Q(), control comes back to P(). In P(), *y (y is address of global x) is changed to x - 1 (x is local to P()).
// Back in P()

 *y = x - 1; // *y = 7-1
 print(x); // Prints 7
After end of Q(), control comes back to main(). In main(), global x is printed.
// Back in main()

print(x); // prints 6 (updated in P()
          //           by *y = x - 1 )
Question 21
Suppose that in a C program snippet, followings statements are used.
i) sizeof(int);
ii) sizeof(int*);
iii) sizeof(int**);
Assuming size of pointer is 4 bytes and size of int is also 4 bytes, pick the most correct answer from the given options.
A
Only i) would compile successfully and it would return size as 4.
B
i), ii) and iii) would compile successfully and size of each would be same i.e. 4
C
i), ii) and iii) would compile successfully but the size of each would be different and would be decided at run time.
D
ii) and iii) would result in compile error but i) would compile and result in size as 4.
Pointer Basics    C Quiz - 101    
Discuss it


Question 21 Explanation: 
Size of all pointer types is same. And whether it is a 'pointer to char' or 'pointer to int' or 'pointer to pointer to int', the size always remain same. That's why all i), ii) and iii) would compile successfully and would result in same size value of 4.
Question 22
Assume int is 4 bytes, char is 1 byte and float is 4 bytes. Also, assume that pointer size is 4 bytes (i.e. typical case)
char *pChar;
int *pInt;
float *pFloat;

sizeof(pChar);
sizeof(pInt);
sizeof(pFloat);
What’s the size returned for each of sizeof() operator?
A
4 4 4
B
1 4 4
C
1 4 8
D
None of the above
Pointer Basics    C Quiz - 101    
Discuss it


Question 22 Explanation: 
Irrespective of the type of pointer, the size for a pointer is always same. So whether it’s pointer to char or pointer to float, the size of any pointer would be same. Even size of a pointer to user defined data type (e.g. struct) is also would be same.
Question 23
In the below statement, ptr1 and ptr2 are uninitialized pointers to int i.e. they are pointing to some random address that may or may not be valid address.
int* ptr1, ptr2;
A
TRUE
B
FALSE
Pointer Basics    C Quiz - 108    
Discuss it


Question 23 Explanation: 
Even though * is placed closer to int, * would be associated to ptr1 only but not to ptr2. It means that “int* ptr1” is equal to “int *ptr1”. That’s why only ptr1 is uninitialized pointer to int. Basically, though both ptr1 and ptr2 are uninitialized variables yet ptr1 is pointer to int while ptr2 is variable of type int. If we really want to make both variables as pointers, we need to mention them as “int *ptr1, *ptr2;”
Question 24
Pick the best statement for the following program snippet:
#include <stdio.h>

int main()
{
 int var;  /*Suppose address of var is 2000 */

 void *ptr = &var;
 *ptr = 5;
 printf("var=%d and *ptr=%d",var,*ptr);
             
 return 0;
}
A
It will print “var=5 and *ptr=2000”
B
It will print “var=5 and *ptr=5”
C
It will print “var=5 and *ptr=XYZ” where XYZ is some random address
D
Compile error
Pointer Basics    C Quiz - 111    
Discuss it


Question 24 Explanation: 
Key point in the above snippet is dereferencing of void pointer. It should be noted that dereferencing of void pointer isn’t allowed because void is an incomplete data type. The correct way to assign value of 5 would be first to typecast void pointer and then use it. So instead of *ptr, one should use *(int *)ptr. Correct answer is d.
Question 25
Consider the following C program.
#include<stdio.h>
void mystery(int *ptra, int *ptrb) 
{
   int *temp;
   temp = ptrb;
   ptrb = ptra;
   ptra = temp;
}
int main() 
{
    int a=2016, b=0, c=4, d=42;
    mystery(&a, &b);
    if (a < c)
       mystery(&c, &a);
    mystery(&a, &d);
    printf("%d\n", a);
}
The output of the program _____________   Note : This question was asked as Numerical Answer Type.
A
2016
B
0
C
4
D
8
Pointer Basics    GATE-CS-2016 (Set 1)    
Discuss it


Question 25 Explanation: 
Note that a and d are not swapped as the function mystery() doesn't change values, but pointers which are local to the function.
Question 26
The value printed by the following program is
void f(int* p, int m)
{
    m = m + 5;
    *p = *p + m;
    return;
}
void main()
{
    int i=5, j=10;
    f(&i, j);
    printf("%d", i+j);
}
A
10
B
20
C
30
D
40
Pointer Basics    GATE-CS-2016 (Set 2)    
Discuss it


Question 26 Explanation: 
#include"stdio.h"

void f(int* p, int m)
{
    m = m + 5;
    *p = *p + m;
    return;
}
int main()
{
    int i=5, j=10;
    f(&i, j);
    printf("%d", i+j);
}
For i, address is passed. For j, value is passed. So in function f, p will contain address of i and m will contain value 10. Ist statement of f() will change m to 15. Then 15 will be added to value at address p. It will make i = 5+15 = 20. j will remain 10. print statement will print 20+10 = 30. So answer is C.
Question 27
Consider the C program below. What does it print?
# include <stdio.h>
# define swapl (a, b) tmp = a; a = b; b = tmp
void swap2 ( int a, int b)
{
        int tmp;
        tmp = a; a = b; b = tmp;
 }
void swap3 (int*a, int*b)
{
        int tmp;
        tmp = *a; *a = *b; *b = tmp;
}
int main ()
{
        int num1 = 5, num2 = 4, tmp;
        if (num1 < num2) {swap1 (num1, num2);}
        if (num1 < num2) {swap2 (num1 + 1, num2);}
        if (num1 > = num2) {swap3 (&num1, &num2);}
        printf ("%d, %d", num1, num2);
}
 /* Add code here. Remove these lines if not writing code */ 
A
5, 5
B
5, 4
C
4, 5
D
4, 4
Pointer Basics    C Quiz - 113    Gate IT 2008    
Discuss it


Question 27 Explanation: 
"if (num1 > = num2) {swap3 (&num1, &num2);}" statement is true, so call by reference will be performed.
Question 28
What will be the output produced by the following C code:
int main()
{
    int array[5][5];
    printf("%d",( (array == *array) && (*array == array[0]) ));
    return 0;    
}
A
1
B
0
C
2
D
-1
Pointer Basics    GATE 2017 Mock    
Discuss it


Question 28 Explanation: 
Given is a 2d array array[5][5].
Suppose base address of array is 2000
array = 2000
*array = 2000
array[0] = 2000
So expression is something like 2000==2000 && 2000==2000 i.e. 1&&1 will return 1.
Question 29
Consider the following C code
int main()
{
   int a = 300;    
   char *b = (char *)&a;
   *++b = 2;
   printf("%d ",a);
   return 0;
}

Consider the size of int as two bytes and size of char as one byte. Predict the output of the following code . Assume that the machine is little-endian.
A
556
B
300
C
Runtime Error
D
Compile Time Error
Pointer Basics    GATE 2017 Mock    
Discuss it


Question 29 Explanation: 
Ans is 556 as char pointer will change the second byte of the integer in the memory and when you print it as a whole integer using %d , its value will be 556 considering little endian scenario. Please read the following link :
http://stackoverflow.com/questions/22030657/little-endian-vs-big-endian
There are 29 questions to complete.

GATE CS Corner


See Placement Course for placement preparation, GATE Corner for GATE CS Preparation and Quiz Corner for all Quizzes on GeeksQuiz.