Govt. Exams
Entrance Exams
The printf() function is defined in the Standard Input/Output library. Therefore, '#include <stdio.h>' must be included at the beginning of the program to use printf() and other I/O functions like scanf(), getchar(), putchar(), etc.
The strlen() function returns the number of characters in a string, excluding the null terminator ('\0').
int main() {
int a = 10;
printf("%d", a += 5);
return 0;
}
The += operator adds 5 to a (a = a + 5 = 10 + 5 = 15), and printf prints the updated value 15.
In C, array indices are 0-based. arr[1][2] refers to the element in the second row (index 1) and third column (index 2) of the 2D array.
getchar() reads a single character from standard input (stdin). While fgetc() can also read a character, getchar() is the standard dedicated function for this purpose.
The correct syntax is 'int *p;' where int is the data type, * indicates pointer, and p is the pointer variable name.
The asterisk (*) symbol is used to declare pointer variables. For example: int *ptr; declares a pointer to an integer.
Operator precedence: multiplication (*) is performed before addition (+). So: 3 * 2 = 6, then 5 + 6 = 11.
Variable names in C cannot start with a digit. They must begin with a letter (a-z, A-Z) or underscore (_). '123myVar' is invalid.