C aptitude
1)
main()
{
printf("%x",-1<<4);
}
output:fff0
Explanation:-16 <- -8 <- -4 <- -2 <- -1
2)
main()
{
printf("\nab");
printf("\bsi");
printf("\rha");
}
output:hai
Explanation:
\n - moves character to next line (ab_)
\b - backspaces character (asi_)
\r - moves cursor to extreme right (hai)
- - cursor
3)
main()
{
printf("%p",main);
}
output:some address is printed
Explanation:%p-prints the address
4)
#define a 10
main()
{
#define a 50
printf("%d",a);
}
output:50
Explanation:preprocessor derictives can be redefined.
5)
main()
{
show();
}
void show()
{
printf("I'm the greatest");
}
output:compile error-type mismatch
Explanation:Default return type for functions is "int"