Login
Register
Dark Mode
Brightness
Profile
Edit Profile
Messages
My favorites
My Updates
Logout
Recent questions tagged pointers
0
votes
1
answer
31
#selfdoubt
What will happen if we dereference a dangling pointer? will it lead to a segmentation fault(core dumped) or an invalid pointer error?
What will happen if we dereference a dangling pointer?will it lead to a segmentation fault(core dumped) or an invalid pointer error?
robinofautumn
497
views
robinofautumn
asked
Dec 8, 2022
Programming in C
programming-in-c
pointers
+
–
1
votes
2
answers
32
Malloc | Free | Dangling Pointer | Prog. & DS
MSQ Consider the following C snippet: #include <stdio.h> int main() { int *ptr = (int*) malloc(100*sizeof(int)); *ptr=33; printf("%d %d\n",ptr,*ptr); // Line X free(ptr); *ptr=37; printf("%d %d\n",ptr,* ... *ptr) is 0 as in Line Y, the allocated heap is freed, and we cannot update it anymore, as ptr is now a dangling pointer
MSQ Consider the following C snippet:#include <stdio.h int main() { int *ptr = (int*) malloc(100*sizeof(int)); *ptr=33; printf("%d %d\n",ptr,*ptr); // Line X free(ptr); *...
Souvik33
630
views
Souvik33
asked
Nov 28, 2022
Programming in C
data-structures
pointers
programming-in-c
+
–
0
votes
0
answers
33
Unacademy test series
Which of the following is/are true regarding the following code snippet? 1:int *p; 2:p = &q; A)*p gives faster retrieval of information than q. B)The size of p is same as size of int. C)Only statement 2 gives an error. D)In statement 1, * is used as a dereferencing operator.
Which of the following is/are true regarding the following code snippet?1:int *p;2:p = &q; A)*p gives faster retrieval of information than q.B)The size of p is same as si...
Pranavpurkar
537
views
Pranavpurkar
asked
Sep 27, 2022
Programming in C
programming-in-c
pointers
unacademy-test-series
bad-question
+
–
0
votes
1
answer
34
ISI2020-PCB-CS: 1.1
Consider the two $\mathrm{C}$ programs given below. C-CODE (I) #include<stdio.h> int main() { int n=2, *ptr=&n ; n*=3; printf ("%d", (*ptr**ptr)*(*ptr**ptr)); } C-CODE(II) #include<stdio.h> int main() { int n=2, *ptr=&n ; n*=3; ... $1296$ Output of (I) is $1296$ and (II) is $216$ Output of both (I) and (II) is $1296$ None of the above
Consider the two $\mathrm{C}$ programs given below.C-CODE (I)#include<stdio.h int main() { int n=2, *ptr=&n ; n*=3; printf ("%d", (*ptr ptr)*(*ptr ptr)); }C-CODE(II)#incl...
admin
389
views
admin
asked
Aug 8, 2022
Programming in C
isi2020-pcb-cs
programming
programming-in-c
pointers
+
–
4
votes
2
answers
35
GO Classes Scholarship 2023 | Test | Question: 18
Consider the following declaration of pointer variable $p.$ int (*p)[10][5]; If the initial value of $p$ is $1000,$ then what will be the value of $p+1?$ It is given that system has $8$ bytes of address size and $4$ bytes of integer size.
Consider the following declaration of pointer variable $p.$int (*p)[10][5];If the initial value of $p$ is $1000,$ then what will be the value of $p+1?$It is given that sy...
GO Classes
881
views
GO Classes
asked
Aug 6, 2022
Programming in C
goclasses-scholarship-test1
numerical-answers
goclasses
array-of-pointers
programming
programming-in-c
pointers
1-mark
+
–
2
votes
1
answer
36
GO Classes Scholarship 2023 | Test | Question: 20
Consider the following declarations of a few variables. int (*p1)[3]; int (*p2)[3]; int (*t1)[2]; int (*t2)[2]; Let the initial values of $p1, p2, t2$ and $t1$ are $1000, 1036, 2000$ and $2040$ respectively. Consider ... is correct but $\text{S2}$ is incorrect $\text{S2}$ is correct but $\text{S1}$ is incorrect Both are correct Both are incorrect
Consider the following declarations of a few variables.int (*p1)[3]; int (*p2)[3]; int (*t1) ; int (*t2) ;Let the initial values of $p1, p2, t2$ and $t1$ are $1000, 1036,...
GO Classes
563
views
GO Classes
asked
Aug 6, 2022
Programming in C
goclasses-scholarship-test1
goclasses
programming
programming-in-c
pointers
array-of-pointers
2-marks
+
–
4
votes
1
answer
37
GO Classes Scholarship 2023 | Test | Question: 22
Consider below two program fragments. Assume malloc is always successful, and sizes are as follows - sizeof (int *)=8 bytes sizeof ( double)=8 bytes sizeof ( char )=1 byte sizeof ( int )=4 byte Program 1 int **p; p = (int ... run time error, but Program $1$ will run fine. Both programs will always run fine. Both programs may produce run time errors.
Consider below two program fragments.Assume malloc is always successful, and sizes are as follows -sizeof (int *)=8 bytes sizeof ( double)=8 bytes sizeof ( char )=1 byte ...
GO Classes
646
views
GO Classes
asked
Aug 6, 2022
Programming in C
goclasses-scholarship-test1
goclasses
programming
programming-in-c
pointers
2-marks
+
–
4
votes
3
answers
38
GO Classes Scholarship 2023 | Test | Question: 30
Consider the following C code fragement - #include<stdio.h> int main() { char t[] = "abcdefghij"; int *p = t; p+=2; char *c = (char *)p; printf("%c", *c); } Which of the following is/are correct? The ... $\textsf{ i "}$ (without quotes).
Consider the following C code fragement -#include<stdio.h int main() { char t[] = "abcdefghij"; int *p = t; p+=2; char *c = (char *)p; printf("%c", *c); }Which of the fol...
GO Classes
1.1k
views
GO Classes
asked
Aug 6, 2022
Programming in C
goclasses-scholarship-test1
goclasses
programming
programming-in-c
array
pointers
multiple-selects
1-mark
+
–
3
votes
1
answer
39
GO Classes Test Series 2024 | Programming | Test 3 | Question: 19
#include<stdio.h> int test(int *a, int *b) { int c = *a-*b; if (c<0) return 0; else return (1 + test(&c, b)); } void main() { int x = 15; int y = 4; int a = test(&x,&y); printf("%d", a); } $2$ $3$ $4$ Run time error since we can not pass the address of local variable c in the function test.
#include<stdio.h int test(int *a, int *b) { int c = *a-*b; if (c<0) return 0; else return (1 + test(&c, b)); } void main() { int x = 15; int y = 4; int a = test(&x,&y); p...
GO Classes
393
views
GO Classes
asked
Apr 30, 2022
Programming in C
goclasses2024-programming-3-weekly-quiz
goclasses
programming
programming-in-c
functions
pointers
parameter-passing
recursion
2-marks
+
–
3
votes
1
answer
40
GO Classes Test Series 2024 | Programming | Test 3 | Question: 21
Consider the following C code where main shows the intended use of the functions relating to struct foo. struct foo { int x; int y; int * p; }; struct foo* make_foo() { struct foo *foo = malloc(sizeof( ... program has a dangling pointer Given program may result in run time error Given program will result in a compile-time error
Consider the following C code where main shows the intended use of the functions relating to struct foo.struct foo { int x; int y; int * p; }; struct foo* make_foo() { st...
GO Classes
555
views
GO Classes
asked
Apr 30, 2022
Programming in C
goclasses2024-programming-3-weekly-quiz
goclasses
programming
programming-in-c
structure
pointers
multiple-selects
2-marks
+
–
3
votes
1
answer
41
GO Classes Test Series 2024 | Programming | Test 3 | Question: 26
What will be the output of the following C program? #include<stdio.h> int main() { static int p[] = {1, 2, 3, 0, 5, 6}; static int *q[] = {p+2, p+1, p, p+3, p+4, p+5}; static int **r[] = {q+4, q+5, q+1, q, q+2, q+3}; int ***pt; pt = r + 2; printf("%d", ***(pt+3)-**(q+1)); }
What will be the output of the following C program?#include<stdio.h int main() { static int p[] = {1, 2, 3, 0, 5, 6}; static int *q[] = {p+2, p+1, p, p+3, p+4, p+5}; stat...
GO Classes
442
views
GO Classes
asked
Apr 30, 2022
Programming in C
goclasses2024-programming-3-weekly-quiz
numerical-answers
goclasses
programming
programming-in-c
array
pointers
array-of-pointers
2-marks
+
–
Page:
« prev
1
2
3
4
5
6
7
...
10
next »
Email or Username
Show
Hide
Password
I forgot my password
Remember
Log in
Register