Recent questions tagged pointers

7 7 votes
1 1 answer
174
174 views
What is the output of the following code?#include <stdio.h int main() { int a[] = {3, 5, 7, 9}; printf("%d %d %d", *(a + 1), 2[a], *(2 + a)); return 0; }$\texttt{5 7 7}$ ...
5 5 votes
1 1 answer
193
193 views
What is the output of the following code?#include <stdio.h int main() { int a[] = {2, 4, 6, 8}; int *p = a; p = p + 2; printf("%d %d", *p, p[-1]); return 0; }$\texttt{6 4...
6 6 votes
1 1 answer
204
204 views
What is the output of the following code?#include <stdio.h int main() { int arr[] = {10, 20, 30}; int *p = arr; printf("%d %d", *p, *(arr + 2)); return 0; }$\texttt{10 20...
7 7 votes
3 3 answers
222
222 views
What is the output of the following code?#include <stdio.h int main() { int *p; printf("%d", *p); return 0; }$\texttt{0}$ $\texttt{Garbage value}$ $\texttt{Compilation er...
6 6 votes
2 2 answers
191
191 views
What is the output of the following code?#include <stdio.h void change(int *p, int q) { *p = *p + q; q = q + 5; *p = *p + q; } int main() { int a = 2, b = 3; change(&a, b...
6 6 votes
3 3 answers
218
218 views
What is the output of the following code?#include <stdio.h int main() { int a = 5, b = 8; int *p = &a; int *q = &b; q = p; *q = *q + b; printf("%d %d", a, b); return 0; }...
7 7 votes
2 2 answers
211
211 views
What is the output of the following code?#include <stdio.h int main() { int a = 10; int *p = &a; *p = *p + 5; a = a + 2; printf("%d", *p); return 0; }$\texttt{10}$ $\text...
5 5 votes
2 2 answers
233
233 views
What is the output of the following code?#include <stdio.h int main() { int a = 25; int *p = &a; printf("%d %d", a, *p); return 0; }$\texttt{25 25}$ $\texttt{25 address}$...
7 7 votes
3 3 answers
239
239 views
What is the output of the following code?#include <stdio.h void update(int *p, int *q) { *p = *p + 2; *q = *q + 3; *p = *p + *q; } int main() { int a = 5; update(&a, &a);...
7 7 votes
1 1 answer
233
233 views
What is the output of the following code?#include <stdio.h int solve(int n) { static int x = 1; if (n == 0) return x; x = x + n; return solve(n - 1); } int main() { print...
7 7 votes
1 1 answer
221
221 views
What is the output of the following code?#include <stdio.h int main() { int a = 5, b = 10; int *p = &a; int q = &p; q = q + 3; p = &b; q = q + a; printf("%d %d", a, ...
7 7 votes
1 1 answer
216
216 views
What is the output of the following code?#include <stdio.h void change(int *p, int *q) { *p = *p + 4; *q = *p + *q; p = q; *p = *p - 3; } int main() { int a = 6, b = 10; ...
7 7 votes
1 1 answer
224
224 views
What is the output of the following code?#include <stdio.h int main() { int a = 8, b = 12; int *p = &a; int *q = &b; *p = *p + *q; q = p; *q = *q - 5; printf("%d %d", a, ...
9 9 votes
2 2 answers
374
374 views
What is the output of the following code?#include <stdio.h int main() { int a = 10, b = 20; int *p, *q; p = &a; q = &b; *p = *p + 5; *q = *p + *q; p = q; *p = *p - 10; pr...
2 2 votes
1 1 answer
256
256 views
Consider the following C program:What is the output printed by the above program?____ // gateastra.com
11 11 votes
3 3 answers
1.8k
1.8k views
Consider the following ANSI-C program.#include <stdio.h int main(){ int *ptr, a, b, c; a=5; b=11; c=20; ptr=&a; *ptr=c; ptr=&c; a=*(&b); c=*ptr-a; printf("%d",c); return(...
0 0 votes
0 0 answers
182
182 views
0 0 votes
1 1 answer
484
484 views
Consider the below statements:S1: Life time of dynamically allocated memory in heap segment is entire program.S2: NULL pointer dereferencing error and dangling pointer bo...
1 1 vote
1 1 answer
574
574 views
What will be the output of the following program? #include <stdio.h int main() { int i[] = {1,2,3}, j[] = {1,2,3}; int *p=i,*q=j; while ((*p++ = *q++) != 3) { printf("%d"...
1 1 vote
1 1 answer
626
626 views
Which of the following defines a variable ‘a’ as an array of pointers to integers? (a) int *b[10], a[10]; (b) int *b, a[10]; (c) int b, *a[10]; (d) int b, (*a)[10];I got ...
1 1 vote
1 answers 1 answer
484
484 views
What size should we use for Pointers for GATE? Pointers are architecture dependent so they have variable size so which architecture's pointer size should we assume?
1 1 vote
2 2 answers
537
537 views
What would be the equivalent pointer expression for referring the array element $\operatorname{ar}[\mathrm{m}][\mathrm{n}][\mathrm{o}]$$^* (^* (^* (\operatorname{ar})+\ma...
0 0 votes
2 2 answers
305
305 views
Only legal pointer operations:pointer $+$ number $\rightarrow$ pointerpointer $-$ number $\rightarrow$ numberpointer $+$ pointer $\rightarrow$ pointerpointer $-$ pointer ...
1 1 vote
2 2 answers
390
390 views
#include<stdio.h void main() { int arr[]={1, 2, 3, 4, 5}; int *p=arr; printf("%d", *p++); printf("%d", *(p+1)); }Find the output of the above code?$1,2$$1,3$$2,3$$1,4$
0 0 votes
2 2 answers
389
389 views
Consider the following code:#include<stdio.h void f1(char *x, char *y) { char *t1; t 1 = x; x= y; y = t 1;} void f2(char x, char y) { char *t1 ; t1 = *x; *x = *y; *y = ...
0 0 votes
1 1 answer
341
341 views
Consider following C program :#include<stdio.h int main() { int x[]={2,4,6,8,10}; int a, b=0, * y = x+4; for(a = 0; a<5; a++) { b=b+(*y -a) - *(y -a); } printf("%d\n", b)...
0 0 votes
1 1 answer
239
239 views
Which of the following is correct way to declare a functional pointer in C?int *func (int, int);int (*func) (int, int);int (func*) (int, int);int *func* (int, int);
0 0 votes
1 1 answer
258
258 views
What will be the output of the following $\text{C}$ code?#include<stdio.h void main() { int arr[5]={10,20,30,40,50}; int *p = (int*) (&arr+1); printf("\%d\%d", *(arr + 1)...
0 0 votes
1 1 answer
289
289 views
Which of the following statements about pointers in $C$ are TRUE.Pointers can be used to access array elementsPointers can store the address of another pointerPointers ar...
0 0 votes
1 1 answer
337
337 views
Consider the following code segment:int arr [] = {0,1,2,3,4}; int i=1, *ptr; ptr = arr + 2;arrange the following printf statements in the increasing order of their output...