Entrance Exams
Govt. Exams
malloc() returns a void pointer (void*) which can be cast to any pointer type. It returns NULL if memory allocation fails.
All three methods are valid. Option A initializes with size 5, option B auto-determines size from initialization, and option C declares without initialization.
sizeof() is a unary operator that returns the number of bytes occupied by a variable or data type in memory.
The * operator is the dereference operator that accesses the value at a memory address. The & operator gets the address of a variable.
Both 'const int x = 10;' and 'int const x = 10;' are valid ways to declare constants in C. The const keyword can appear before or after the type.
stdio.h (Standard Input/Output header) contains declarations for printf(), scanf(), and other I/O functions.
p is a pointer storing the address of a. *p (dereferencing) gives the value at that address, which is 5. So both a and *p print 5.
When an array is passed to a function in C, it decays to a pointer pointing to the first element. This is why changes made in the function affect the original array.
x=5 is greater than 3, so the condition (x > 3) evaluates to true. The if block executes, printing 'Greater'.
In C, void function() { } is correct. In some contexts, void function(void) { } is more explicit. Options B and C use invalid keywords for this purpose.