Login
Register
Dark Mode
Brightness
Profile
Edit Profile
Messages
My favorites
My Updates
Logout
Recent questions tagged pointers
5
votes
1
answer
61
GO Classes Test Series 2024 | Programming | Test 3 | Question: 29
Mark all options which are likely to create problems with memory, i.e., run time error or have a memory leak. Assume malloc is always successful, and sizes are as follows - sizeof(int *) = 8 bytes sizeof(double) = 8 bytes sizeof(char) = 1 ... 4 int *p = malloc(sizeof(char)); *p = 0; Program $1$ Program $2$ Program $3$ Program $4$
Mark all options which are likely to create problems with memory, i.e., run time error or have a memory leak. Assume malloc is always successful, and sizes are as follows...
GO Classes
579
views
GO Classes
asked
Apr 30, 2022
Programming in C
goclasses2024-programming-3-weekly-quiz
goclasses
programming
programming-in-c
pointers
multiple-selects
2-marks
+
–
4
votes
1
answer
62
GO Classes Test Series 2024 | Programming | Test 3 | Question: 30
What will be the output of the following program? It is given that $\textsf{sizeof(int) = 4}$ and $\textsf{sizeof(int *) = 8.}$ #include<stdio.h> main(){ void** p = 1000; int* q = ((int*)(p + 1)) - 1; printf("%u", q); } $1000$ $1008$ $1004$ Error, since $p+1$ is not allowed as $p$ is declared as void.
What will be the output of the following program?It is given that $\textsf{sizeof(int) = 4}$ and $\textsf{sizeof(int *) = 8.}$#include<stdio.h main(){ void p = 1000; int...
GO Classes
346
views
GO Classes
asked
Apr 30, 2022
Programming in C
goclasses2024-programming-3-weekly-quiz
goclasses
programming
programming-in-c
pointers
2-marks
+
–
12
votes
3
answers
63
GATE CSE 2022 | Question: 11
What is printed by the following $\text{ANSI C}$ program? #include<stdio.h> int main(int argc, char *argv[]) { int x = 1, z[2] = {10, 11}; int *p = NULL; p = &x; *p = 10; p = &z[1]; *(&z[0] + 1) += 3; printf(“%d, %d, %d\n”, x, z[0], z[1]); return 0; } $1, 10, 11$ $1, 10, 14$ $10, 14, 11$ $10, 10, 14$
What is printed by the following $\text{ANSI C}$ program?#include<stdio.h int main(int argc, char *argv[]) { int x = 1, z = {10, 11}; int *p = NULL; p = &x; *p = 10; p =...
Arjun
5.8k
views
Arjun
asked
Feb 15, 2022
Programming in C
gatecse-2022
programming
programming-in-c
pointers
output
1-mark
+
–
2
votes
1
answer
64
GATE Overflow Test Series | Mock GATE | Test 6 | Question: 28
What will be the output of the following C program? #include<stdio.h> #include<stdlib.h> struct node { int value; struct node * next; }; struct node* init_list() { struct node* list = malloc(sizeof(struct node)); ... list = init_list(); printf("%d", list-> value); } $5$ Garbage Value $6$ Possible Runtime Error
What will be the output of the following C program?#include<stdio.h #include<stdlib.h struct node { int value; struct node * next; }; struct node* init_list() { struct no...
Arjun
133
views
Arjun
asked
Jan 30, 2022
Programming in C
go2025-mockgate-6
programming
programming-in-c
pointers
1-mark
+
–
0
votes
2
answers
65
Pointers
main () { static char *s[] = { “ice”, “green”, “cone”, “please”, }; static char **ptr[] = {s+3,s+2,s+1,s}; char ***p = ptr; printf(“\n%s”, **++p); printf(“\n%s”, *--*++p+3); printf(“\n%s”, *p[-2]+3); printf(“\n%s”, p[-1][-1]+1); } cone, ase, reen ice, green, cone green, cone, please None of the above
main () {static char *s[] = {“ice”,“green”,“cone”,“please”,};static char ptr[] = {s+3,s+2,s+1,s};char *p = ptr;printf(“\n%s”, ++p);printf(“\n%s�...
prerona_99
545
views
prerona_99
asked
Oct 31, 2021
Programming in C
pointers
programming-in-c
array-of-pointers
+
–
0
votes
0
answers
66
C-Programming doubt on operator precedence of prefix and postfix ++ with dereferencing operator *.
Operator precedence rule for prefix and postfix ++For C programming is the above mentioned article considered as standard, Is there any standard compiler or C standard that GATE follows for evaluation, and are there any more such exceptions, please do let me know?
Operator precedence rule for prefix and postfix ++For C programming is the above mentioned article considered as standard, Is there any standard compiler or C standard th...
Pawan Nirpal
595
views
Pawan Nirpal
asked
Oct 29, 2021
Programming in C
programming-in-c
pointers
+
–
0
votes
3
answers
67
&* Operator in C
#include <stdio.h> int main() { int a=20; int *ptr=&a; int x=a; printf ("%p\n",&*ptr); printf ("%p\n",&a); return 0; } Why both printf() line printing the same address value??
#include <stdio.h>int main(){ int a=20; int *ptr=&a; int x=a; printf ("%p\n",&*ptr); printf ("%p\n",&a); return 0;}Why both printf() line printing the s...
lalitver10
700
views
lalitver10
asked
Oct 23, 2021
Programming in C
programming
programming-in-c
pointers
+
–
17
votes
2
answers
68
GATE CSE 2021 Set 2 | Question: 35
Consider the following $\text{ANSI C}$ program: #include <stdio.h> #include <stdlib.h> struct Node{ int value; struct Node *next;}; int main( ) { struct Node *boxE, *head, *boxN; int index=0; boxE=head= (struct ... which will be reported as an error by the compiler It dereferences an uninitialized pointer that may result in a run-time error
Consider the following $\text{ANSI C}$ program:#include <stdio.h #include <stdlib.h struct Node{ int value; struct Node *next;}; int main( ) { struct Node *boxE, *head, *...
Arjun
9.6k
views
Arjun
asked
Feb 18, 2021
Programming in C
gatecse-2021-set2
programming-in-c
normal
pointers
structure
2-marks
+
–
2
votes
1
answer
69
GATE Overflow Test Series | Mock GATE | Test 4 | Question: 44
What is the output of the following program? #include<stdio.h> void fun1(int *x); void fun2(int *y); int a; int main() { a=5; fun1(&a); printf("%d\n",a); return 0; } void fun1(int *b) { int a = *b-2; fun2(&a); *b = a+ ... ,a); } void fun2(int *c) { *c-=a; printf("%d",*c); } $420$ $-2-2-1$ $-234$ $-2-1-1$
What is the output of the following program?#include<stdio.h void fun1(int *x); void fun2(int *y); int a; int main() { a=5; fun1(&a); printf("%d\n",a); return 0; } void f...
gatecse
181
views
gatecse
asked
Feb 1, 2021
Programming in C
go2025-mockgate-4
programming-in-c
output
pointers
+
–
3
votes
1
answer
70
GATE Overflow Test Series | Mock GATE | Test 3 | Question: 38
What is the output of the following program? $($Assume that the value returned by the malloc call is $1001.)$ #include<stdio.h> #include<stdlib.h> void fun(int **y); int main() { int *x = (int*)malloc(sizeof(int)); *x = 132; fun(& ... ",*y); } $21$ $132$ $1001$ $1001$ $21$ $1001$ $1001$ garbage $1001$ $21$ $21$ $132$
What is the output of the following program?$($Assume that the value returned by the malloc call is $1001.)$#include<stdio.h #include<stdlib.h void fun(int y); int main(...
gatecse
168
views
gatecse
asked
Jan 26, 2021
Programming in C
go2025-mockgate-3
programming-in-c
output
pointers
+
–
5
votes
1
answer
71
GATE Overflow Test Series | Mock GATE | Test 1 | Question: 42
What will be the output of the following C program? #include<stdio.h> void foo(int a, int *p1, int **p2) { static int b; *p1 = 6; *p2 = &b; } int main() { int a, *p1 = &a; a = 9; foo(a, p1, &p1); printf("%d,%d",a, *p1); } $6,0$ $9,6$ $6,6$ Garbage Value
What will be the output of the following C program?#include<stdio.h void foo(int a, int *p1, int p2) { static int b; *p1 = 6; *p2 = &b; } int main() { int a, *p1...
gatecse
540
views
gatecse
asked
Jan 3, 2021
Programming in C
go2025-mockgate-1
pointers
parameter-passing
programming-in-c
+
–
1
votes
1
answer
72
GATE Overflow Test Series | Mixed Subjects | Test 2 | Question: 12
If the values printed by the following C code are $a$ and $b,$ $a + b =$ _____ #include<stdio.h> int main() { int array[5] = {1, 2, 3, 4, 5}; int *p = array; printf("%ld\t%ld", p - array, p - (int*)&array); }
If the values printed by the following C code are $a$ and $b,$ $a + b =$ _____#include<stdio.h int main() { int array[5] = {1, 2, 3, 4, 5}; int *p = array; printf("%ld\t%...
gatecse
130
views
gatecse
asked
Aug 30, 2020
Programming in C
go2025-mix-2
numerical-answers
pointers
array
+
–
1
votes
1
answer
73
GATE Overflow Test Series | Mixed Subjects | Test 2 | Question: 13
What will be the output of the following C code? #include<stdio.h> int main() { int array[4] = {1, 2, 3, 4}; printf("%d\n", *array + array[0] + *array+1 + array[array[1]]); }
What will be the output of the following C code?#include<stdio.h int main() { int array[4] = {1, 2, 3, 4}; printf("%d\n", *array + array[0] + *array+1 + array[array ]); }...
gatecse
67
views
gatecse
asked
Aug 30, 2020
Programming in C
go2025-mix-2
numerical-answers
pointers
+
–
2
votes
1
answer
74
GATE Overflow Test Series | Data Structures | Test 1 | Question: 23
What will be the output of the C program? #include<stdio.h> int main() { int a[][4] = {0, 1, 2, 3, 4, 5, 6, 7}; int (*ptr)[4] = a; printf("%d %d ", (*ptr)[0], (*ptr)[1]); ++ptr; printf("%d %d\n", (*ptr)[0], (*ptr)[1]); return 0; } $0 \ 1 \ 3 \ 4$ $0 \ 1 \ 4 \ 5$ $0 \ 1 \ 2 \ 3$ $0 \ 1 \ 6 \ 7$
What will be the output of the C program?#include<stdio.h int main() { int a[][4] = {0, 1, 2, 3, 4, 5, 6, 7}; int (*ptr)[4] = a; printf("%d %d ", (*ptr)[0], (*ptr) ); ++p...
gatecse
282
views
gatecse
asked
Aug 9, 2020
DS
go2025-ds-1
array
pointers
+
–
6
votes
3
answers
75
GATE Overflow Test Series | Programming | Test 1 | Question: 1
Consider the following C code fragment ( denote further statements): int main() { int my_array[30][40][50]; init_array(&my_array); ... } Which of the following is a valid declaration for the function init_array? Mark all the correct ... array)[30][40][50]); void init_array(int *** array); void init_array(int ** array[30][40]);
Consider the following C code fragment (… denote further statements):int main() { int my_array[30][40][50]; init_array(&my_array); ... }Which of the following is a vali...
gatecse
679
views
gatecse
asked
Jul 26, 2020
Programming in C
go2025-programming-1
parameter-passing
pointers
multiple-selects
+
–
9
votes
1
answer
76
GATE Overflow Test Series | Programming | Test 1 | Question: 3
What will be the output of the following C program: #include<stdio.h> int main() { char* disease = "COVID-19"; (*disease)++; printf("%s",disease); } DPWJE-$20$ DOVID-$19$ COVID-$19$ Possible Runtime Error
What will be the output of the following C program:#include<stdio.h int main() { char* disease = "COVID-19"; (*disease)++; printf("%s",disease); }DPWJE-$20$DOVID-$19$COVI...
gatecse
640
views
gatecse
asked
Jul 26, 2020
Programming in C
go2025-programming-1
pointers
+
–
9
votes
1
answer
77
GATE Overflow Test Series | Programming | Test 1 | Question: 5
Which of the below statement is a correct way to print the statement “Hello World”? (Mark all the appropriate choices) printf ("Hello World"); printf ("%s", "Hello World"); char *p = "Hello"; printf(p, " World"); char * p = "Hello %s"; char *q = "World"; printf(p,q);
Which of the below statement is a correct way to print the statement “Hello World”? (Mark all the appropriate choices)printf ("Hello World");printf ("%s", "Hello Worl...
gatecse
595
views
gatecse
asked
Jul 26, 2020
Programming in C
go2025-programming-1
pointers
multiple-selects
+
–
6
votes
1
answer
78
GATE Overflow Test Series | Programming | Test 1 | Question: 6
Consider the following C program: #include<stdio.h> extern int getMyMonth(); int main() { enum Month {January, February, March, April, May, June, July, August, September, October, November, December}; int my_month = getMyMonth(); ... above program if the external function getMyMonth() returns $1?$ $31$ $30$ $28$ None of the above
Consider the following C program:#include<stdio.h extern int getMyMonth(); int main() { enum Month {January, February, March, April, May, June, July, August, September, O...
gatecse
639
views
gatecse
asked
Jul 26, 2020
Programming in C
go2025-programming-1
pointers
+
–
3
votes
1
answer
79
GATE Overflow Test Series | Programming | Test 1 | Question: 7
Which of the following is the correct replacement for "<my_decl>" to define a global integer variable? #include<stdio.h> <my_decl> my_global; int main() { printf("%d", my_global); } global int extern int static int int
Which of the following is the correct replacement for "<my_decl>" to define a global integer variable?#include<stdio.h <my_decl my_global; int main() { printf("%d", my_gl...
gatecse
390
views
gatecse
asked
Jul 26, 2020
Programming in C
go2025-programming-1
pointers
+
–
3
votes
1
answer
80
GATE Overflow Test Series | Programming | Test 1 | Question: 8
What will be the output of the following C program? #include<stdio.h> struct my_struct { int field1; float field2; double field3; }; int main() { struct my_struct try1, try2; try1.field1 = 10.1; try1.field2 = 10.1; try1.field3 = 10.1; ... try2.field3); } $10\; 10.1\; 10.1$ $10.1\; 10.1\; 10.1$ Possible Runtime Error Garbage Value
What will be the output of the following C program?#include<stdio.h struct my_struct { int field1; float field2; double field3; }; int main() { struct my_struct try1, try...
gatecse
399
views
gatecse
asked
Jul 26, 2020
Programming in C
go2025-programming-1
pointers
+
–
3
votes
1
answer
81
GATE Overflow Test Series | Programming | Test 1 | Question: 9
Which of the following correctly declare a pointer to function returning a pointer to an integer and accepting a pointer to a one-dimensional integer array of size $10$ as input? int * (*p)(int * my_array[10]) int * (*p)(int (* my_array)[10]) int * p(int * my_array[10]) int * (*p) (int * my_array)
Which of the following correctly declare a pointer to function returning a pointer to an integer and accepting a pointer to a one-dimensional integer array of size $10$ a...
gatecse
319
views
gatecse
asked
Jul 26, 2020
Programming in C
go2025-programming-1
pointers
+
–
6
votes
1
answer
82
GATE Overflow Test Series | Programming | Test 1 | Question: 11
What will be the output of the following C program?(Assume IEEE -$754$ standard being Used) #include<stdio.h> int main() { float a = 8.0625; if(a == 8.0625) { printf("1"); } else { printf("0"); } }
What will be the output of the following C program?(Assume IEEE -$754$ standard being Used)#include<stdio.h int main() { float a = 8.0625; if(a == 8.0625) { printf("1"); ...
gatecse
562
views
gatecse
asked
Jul 26, 2020
Programming in C
go2025-programming-1
numerical-answers
pointers
+
–
5
votes
1
answer
83
GATE Overflow Test Series | Programming | Test 1 | Question: 15
Consider the following C structure declaration. struct abc { double myfield1; int myfield2; }myobj; Which of the following pointer declarations would not cause any undefined behaviour for the above given structure fields? char *p = (char*) & ... (int*) &myobj.myfield1; double *p = (double*) &myobj.myfield2; Both $B$ and $C$
Consider the following C structure declaration.struct abc { double myfield1; int myfield2; }myobj;Which of the following pointer declarations would not cause any undefine...
gatecse
664
views
gatecse
asked
Jul 26, 2020
Programming in C
go2025-programming-1
pointers
+
–
9
votes
1
answer
84
GATE Overflow Test Series | Programming | Test 1 | Question: 16
If the values printed by the following C program are $a,b,c$ and $d$ respectively, then $a+2b+3c+4d = $_____ #include<stdio.h> #include<string.h> int main() { char* p = "GATE Overflow"; char q[] = "GATE Overflow"; printf("%lu %lu %lu %lu", sizeof(*p), sizeof(q), strlen(p), strlen(q)); }
If the values printed by the following C program are $a,b,c$ and $d$ respectively, then $a+2b+3c+4d = $_____#include<stdio.h #include<string.h int main() { char* p = "GAT...
gatecse
684
views
gatecse
asked
Jul 26, 2020
Programming in C
go2025-programming-1
numerical-answers
pointers
strings
+
–
6
votes
2
answers
85
GATE Overflow Test Series | Programming | Test 1 | Question: 17
Consider the following C program fragment: #include<stdio.h> int my_array[20][10]; int main() { int *p = my_array, i; for(i = 0; i < 10*20; i++) { *(p+X) = i; } ... } The correct replacement for 'X' so that every position in the array ... + (i / 20) * 10; (i / 10) * 20 + (i% 10) * 20; (i % 10) + (i / 10) * 10;
Consider the following C program fragment:#include<stdio.h int my_array[20][10]; int main() { int *p = my_array, i; for(i = 0; i < 10*20; i++) { *(p+X) = i; } ... }The co...
gatecse
382
views
gatecse
asked
Jul 26, 2020
Programming in C
go2025-programming-1
pointers
+
–
12
votes
2
answers
86
GATE Overflow Test Series | Programming | Test 1 | Question: 20
What will be the output of the following C program? #include <stdio.h> int main() { int a[10][20][30]={0}; printf("%d %d %d",&a+1 - &a, a[10][20] - a[10][10], a[10] - a[5]); return 0; } 1 300 100 600 300 100 1 100 5 None of the above
What will be the output of the following C program?#include <stdio.h int main() { int a[10][20][30]={0}; printf("%d %d %d",&a+1 - &a, a[10][20] - a[10][10], a[10] - a[5])...
gatecse
779
views
gatecse
asked
Jul 26, 2020
Programming in C
go2025-programming-1
pointers
+
–
6
votes
2
answers
87
GATE Overflow Test Series | Programming | Test 1 | Question: 21
What will be the output of the following C program? #include <stdlib.h> int* fun(); int main() { int a = 5; int *p = &a; p = fun(); printf("%d",*p); return 0; } int* fun() { int *a =(int*) malloc(sizeof(int)); *a = 1; return a; }
What will be the output of the following C program?#include <stdlib.h int* fun(); int main() { int a = 5; int *p = &a; p = fun(); printf("%d",*p); return 0; } int* fun() ...
gatecse
277
views
gatecse
asked
Jul 26, 2020
Programming in C
go2025-programming-1
numerical-answers
pointers
+
–
7
votes
1
answer
88
GATE Overflow Test Series | Programming | Test 1 | Question: 22
How many $1s$ will be printed by the below function when called with the argument $9?$ (Assume sizeof int as $4$ bytes) #include <stdio.h> int fun(int a) { char *arr[] = {"0000", "0001","0010","0011"," ... ;%s", arr[d]); d = (*p) & 0xf; printf("%s ", arr[d]); p--; } }
How many $1s$ will be printed by the below function when called with the argument $9?$ (Assume sizeof int as $4$ bytes)#include <stdio.h int fun(int a) { char *arr[] = {"...
gatecse
630
views
gatecse
asked
Jul 26, 2020
Programming in C
go2025-programming-1
numerical-answers
pointers
+
–
Page:
« prev
1
2
3
4
5
6
7
8
...
10
next »
Email or Username
Show
Hide
Password
I forgot my password
Remember
Log in
Register