Pointers
- What will be the output of the following C code?
#include <stdio.h>
int main()
{
const int num[5] = {11, 21, 31, 41, 51};
int *ptr;
ptr = num + 3;
*ptr = 50;
printf("%d\n", num[3]);
}
-
View Hint View Answer Discuss in Forum
NA
Correct Option: E
50
- What will be the output of the following C code?
#include <stdio.h>
int main()
{
int num[6] = {6, 7, 8, 9, 10};
printf("%d\n", *num);
}
-
View Hint View Answer Discuss in Forum
NA
Correct Option: E
6
- What will be the output of the following C code?
#include <stdio.h>
void main()
{
int n = 0;
int *p = &n;
printf("%p\n", p);
p++;
printf("%p\n ", p);
}
-
View Hint View Answer Discuss in Forum
NA
Correct Option: B
0x7ffc391e1404
0x7ffc391e1408
- What will be the output of the following C code?
#include <stdio.h>
void main()
{
int var = 101;
int *p = &var;
printf("%d\n", *p);
}
-
View Hint View Answer Discuss in Forum
NA
Correct Option: A
101
- What will be the output of the following C code?
#include <stdio.h>
void main()
{
int var = 10;
int *p = &15;
printf("%p\n", p);
}
-
View Hint View Answer Discuss in Forum
NA
Correct Option: D
Compilation Error
main.c: In function ‘main’:
main.c:5:18: error: lvalue required as unary ‘&’ operand
int *p = &15;