ExamVeda
Login
Home
51
Find the output of the following program.
void main()
{
   printf("%d, %d", sizeof(int *), sizeof(int **));
}
Discuss
Answer & Solution
Answer: Option C
Solution:

Every pointer regardless of its type whereas single pointer or pointer to pointer, needs only 2 bytes.

Size of pointer and int is 2 bytes in Turbo C compiler on windows 32 bit machine. So size of pointer is compiler specific. But generally most of the compilers are implemented to support 4 byte pointer variable in 32 bit and 8 byte pointer variable in 64 bit machine.

52
Find the output of the following program.
void main()
{
   int i=10;  /* assume address of i is 0x1234ABCD */
   int *ip=&i;
   int **ipp=&&i;
   printf("%x,%x,%x", &i, ip, *ipp);  
}
Discuss
Answer & Solution
Answer: Option D
Solution:

&& is logical AND operator and this operator requires two operands.

53
Which of the following statements are true after execution of the program.
void main()
{
   int a[10], i, *p;
   a[0] = 1;
   a[1] = 2;
   p = a;
   (*p)++;
}
Discuss
Answer & Solution
Answer: Option B
Solution:
After the execution of the program, the value of the first element of the array 'a' will be modified. Let's break down the code step by step:

a[0] = 1;: Sets the first element of the array 'a' to 1.
a[1] = 2;: Sets the second element of the array 'a' to 2.
p = a;: Assigns the address of the first element of the array 'a' to the pointer 'p'.
(*p)++;: Increments the value at the memory location pointed to by 'p'. Since 'p' points to the first element of 'a', it increments the value of 'a[0]'.

After the execution of the program, the value of a[0] will be 2.

Therefore, the correct statement is Option B: a[0] = 2.
54
What is the base data type of a pointer variable by which the memory would be allocated to it?
Discuss
Answer & Solution
Answer: Option E
No explanation is given for this question. Let's Discuss on Board
55
What would be the output for the following Turbo C code?
#include<stdio.h>
void main()
{
   int a[]={ 1, 2, 3, 4, 5 }, *p;
   p=a;
   ++*p;
   printf("%d ", *p);
   p += 2;
   printf("%d", *p);
}
Discuss
Answer & Solution
Answer: Option D
No explanation is given for this question. Let's Discuss on Board
56
char* myfunc(char *ptr)
{
   ptr+=3;
   return(ptr);
}

void main()
{
   char *x, *y;
   x = "EXAMVEDA";
   y = myfunc(x);
   printf("y=%s", y);
}

What will be printed when the sample code above is executed?
Discuss
Answer & Solution
Answer: Option C
No explanation is given for this question. Let's Discuss on Board
57
char *ptr;
char myString[] = "abcdefg";
ptr = myString;
ptr += 5;

what string does ptr point to in the sample code above?
Discuss
Answer & Solution
Answer: Option A
No explanation is given for this question. Let's Discuss on Board
58
What will be the output of the following C code?
#include <stdio.h>
int main()
{
    int i = 10;
    int *p = &i;
    foo(&p);
    printf("%d ", *p);
    printf("%d ", *p);
}
void foo(int **const p)
{
    int j = 11;
    *p = &j;
    printf("%d ", **p);
}
Discuss
Answer & Solution
Answer: Option B
No explanation is given for this question. Let's Discuss on Board
59
What will be the output of the following C code?
#include <stdio.h>
void main()
{
    char *s= "hello";
    char *p = s;
    printf("%c\t%c", *(p + 3),  s[1]);
}
Discuss
Answer & Solution
Answer: Option D
No explanation is given for this question. Let's Discuss on Board
60
What will be the output of the following C code?
#include <stdio.h>
void main()
{
    int a[3] = {1, 2, 3};
    int *p = a;
    int **r = &p;
    printf("%p %p", *r, a);
}
Discuss
Answer & Solution
Answer: Option C
No explanation is given for this question. Let's Discuss on Board