Govt Exams
The 'char' data type in C occupies 1 byte of memory and can store a single character.
In C, a pointer to an integer is declared using 'int *ptr;' where '*' indicates pointer declaration.
When 'static' is used with a global variable, it restricts its scope to the current file (internal linkage), making it not accessible from other files.
#include
int main() {
int x = 5;
int y = ++x * ++x;
printf("%d", y);
return 0;
}
The expression ++x * ++x modifies x twice without an intervening sequence point, causing undefined behavior.
#include
int main() {
char c = 'A';
printf("%d", c);
return 0;
}
The %d format specifier prints the ASCII value of the character. 'A' has ASCII value 65.
Global variables are stored in the data segment (also called BSS segment for uninitialized globals). Local variables use the stack.
Function pointers require parentheses around the pointer name: int (*func)(). Option D declares a function returning int pointer, not a function pointer.
#define is a preprocessor directive replaced before compilation, while const creates an actual variable. const occupies memory; #define does not.
#include
int main() {
char str[] = "Hello";
printf("%c", str[1]);
return 0;
}
String indexing starts at 0. str[0] = 'H', str[1] = 'e'.
The 'long' modifier cannot be used with 'float'. You can only use 'double' or 'long double' for longer floating-point types.