Pointers
- What will be the output of the following C code?
#include <stdio.h>
int main()
{
int n = 101;
int *ptr = &n;
fun(&ptr);
printf("%d ", *ptr);
}
void fun(int *const *ptr)
{
int k = 100;
*ptr = &k;
printf("%d ", **ptr);
}
-
View Hint View Answer Discuss in Forum
NA
Correct Option: D
Compilation Error
- What will be the output of the following C code?
#include <stdio.h>
int main()
{
int n = 58, *ptr = &n;
function(&ptr);
printf("%d ", *ptr);
return 0;
}
void function(int **ptr)
{
int k = 12;
*ptr = &k;
printf("%d ", **ptr);
}
-
View Hint View Answer Discuss in Forum
NA
Correct Option: D
12 12
- What will be the output of the following C code?
#include <stdio.h>
int main()
{
int num = 45, *ptr = #
function(&num);
printf("%d ", *ptr);
}
void function(int *ptr)
{
int L = 20;
ptr = &L;
printf("%d ", *ptr);
}
-
View Hint View Answer Discuss in Forum
NA
Correct Option: A
20 45
- What will be the output of the following C code?
#include <stdio.h>
void fun(int*);
int main()
{
int n = 14, *ptr = &n;
fun(ptr++);
}
void fun(int *ptr)
{
printf("%d\n", *ptr);
}
-
View Hint View Answer Discuss in Forum
NA
Correct Option: A
0.000000
- What will be the output of the following C code?
#include <stdio.h>
void fun(int*);
int main()
{
int n = 101, *ptr = &n;
fun(ptr++);
}
void fun(int *ptr)
{
printf("%d\n", *ptr);
}
-
View Hint View Answer Discuss in Forum
NA
Correct Option: B
101