Pointers
- 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>
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>
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>
void count(int m, int n)
{
printf("%d\n", m);
}
void main()
{
int i = 12, j = 11;
count(i, j);
printf("%d %d\n", i, j);
}
-
View Hint View Answer Discuss in Forum
NA
Correct Option: A
12
12 11
- What will be the output of the following C code?
#include <stdio.h>
void main()
{
char *ptr1 = "Interview Mania";
char *ptr2 = ptr1;
printf("%p %p", ptr2, ptr1);
}
-
View Hint View Answer Discuss in Forum
NA
Correct Option: B
Same memory address is printed