Pointers
- Which of following logical operation can be applied to pointers?
(Assuming initialization int *p = 12; int *q = 13;)
-
View Hint View Answer Discuss in Forum
NA
Correct Option: E
None of these
- What will be the output of the following C code?
#include <stdio.h>
void main()
{
char *str = "PRAYAG";
char *ptr = str;
printf("%c %c", *ptr, str[2]);
}
-
View Hint View Answer Discuss in Forum
NA
Correct Option: A
P A
- What will be the output of the following C code?
#include <stdio.h>
void main()
{
char *str = "AJIT";
char *ptr = str;
printf("%c %c", *(ptr + 2), str[2]);
}
-
View Hint View Answer Discuss in Forum
NA
Correct Option: D
I I
- What will be the output of the following C code?
#include <stdio.h>
void main()
{
char *str = "InterviewMania";
char *ntr = "Mania";
char *ptr = str + ntr;
printf("%c\t%c", *ptr, str[1]);
}
-
View Hint View Answer Discuss in Forum
NA
Correct Option: C
Compilation Error
main.c: In function ‘main’:
main.c:6:25: error: invalid operands to binary + (have ‘char *’ and ‘char *’)
char *ptr = str + ntr;
- What is the size of *p in a 32-bit machine (Assuming initialization as int *p = 12;)?
-
View Hint View Answer Discuss in Forum
NA
Correct Option: B
4