Govt. Exams
Entrance Exams
Parentheses () have the highest precedence among all operators in C. They are always evaluated first in any expression.
The strlen() function returns the length of a string as an int value, representing the number of characters.
Variable names in C must start with a letter or underscore, not a digit. _variable is valid. '2var' starts with digit, 'var-name' contains hyphen (invalid), 'var name' contains space (invalid).
The stdio.h header file contains declarations for standard input/output functions like printf() and scanf().
strlen() returns the length of a string without counting the null terminator ('\0'). For example, strlen("hello") returns 5, not 6.
int a = 10, b = 20;
int c = (a > b) ? a : b;
printf("%d", c);
The ternary operator (condition ? true_value : false_value) evaluates the condition (a > b). Since 10 is not greater than 20, it returns b which is 20.
void is used in two contexts: (1) as a function return type when a function doesn't return a value, and (2) to declare a generic pointer (void *) that can point to any data type.
char arr[10];
Each char occupies 1 byte in memory. An array of 10 chars will occupy 10 × 1 = 10 bytes.
In C, pointers are declared using the asterisk (*) symbol before the variable name. The syntax is 'datatype *pointer_name;'
int x = 5;
printf("%d", x++);
The post-increment operator (x++) returns the current value of x before incrementing. So printf prints 5, and then x becomes 6.