<quiz display="simple"> {What will be the output of the following code? <syntaxhighlight lang="c">
int main(){
int a = 5; int* p = &a; printf("%d", ++*p);
} </syntaxhighlight> |type="{}" /} { 6 } ||p is pointing to the address of a. *p will return the content of a which is 5 and ++ will increment it to 6.
{What will be the output of the following code?
<syntaxhighlight lang="c">
int main(){
char a[] = "Hello World"; char* p = &a; printf("%s", p+2 );
} </syntaxhighlight> |type="()" /} -Compiler Error -World +llo World -Runtime Error
||Since p is a char pointer p+2 will add 2 to p (since sizeof(char) is 1). So, p+2 will be pointing to the string "llo World"
{What will be the output of the following code? <syntaxhighlight lang="c">
int main(){
int a; int* p = &a; printf("%zu", sizeof( *(char*)p ));
} </syntaxhighlight> |type="()" /}
+1 -2 -4 -Compile Error
||p is typecasted to char pointer and then dereferenced. So, returned type will be char and sizeof(char) is 1
</quiz>
<quiz display="simple"> {What will be the output of the following code? <syntaxhighlight lang="c">
int main(){
int a = 5; int* p = &a; printf("%d", ++*p);
} </syntaxhighlight> |type="{}" /} { 6 } ||p is pointing to the address of a. *p will return the content of a which is 5 and ++ will increment it to 6.
{What will be the output of the following code?
<syntaxhighlight lang="c">
int main(){
char a[] = "Hello World"; char* p = &a; printf("%s", p+2 );
} </syntaxhighlight> |type="()" /} -Compiler Error -World +llo World -Runtime Error
||Since p is a char pointer p+2 will add 2 to p (since sizeof(char) is 1). So, p+2 will be pointing to the string "llo World"
{What will be the output of the following code? <syntaxhighlight lang="c">
int main(){
int a; int* p = &a; printf("%zu", sizeof( *(char*)p ));
} </syntaxhighlight> |type="()" /}
+1 -2 -4 -Compile Error
||p is typecasted to char pointer and then dereferenced. So, returned type will be char and sizeof(char) is 1
</quiz>