Govt Exams
strcmp() is the standard library function used to compare two strings. It returns 0 if strings are equal, negative if first string is less, and positive if first string is greater. It's declared in string.h.
Array indexing in C starts from 0. str[0]='H', str[1]='e', str[2]='l', str[3]='l', str[4]='o', str[5]='\0'. Therefore, str[1] is 'e'.
malloc() (memory allocation) is the standard function in C for dynamic memory allocation. It returns a void pointer to the allocated memory. The syntax is: ptr = (type*)malloc(size);
When %d format specifier is used with a char variable, it prints the ASCII value. The ASCII value of 'A' is 65. If it were 'a', the value would be 97.
The correct syntax for declaring a pointer to an integer is 'int *ptr;' where the asterisk (*) indicates that ptr is a pointer. The placement of * before the variable name is crucial.
The break statement exits or terminates the current loop immediately. Option D describes continue (which skips to next iteration), while break actually exits the loop.
Parentheses have the highest precedence in C. Expressions within parentheses are evaluated first, followed by arithmetic operators, then logical operators, and finally assignment operators.
The stdio.h (Standard Input Output) header file contains declarations for printf(), scanf(), and other input/output functions. It is essential for console I/O operations.
In a 32-bit system, the int data type typically occupies 4 bytes (32 bits). This is the standard size for integer types on most 32-bit architectures.
Both char s[] (array notation) and char *s (pointer notation) are valid ways to pass strings to functions in C. C does not have a built-in string type; strings are represented as character arrays or pointers to char.