Professional Documents
Culture Documents
A pointer is a variable that refers to the address of a value. It makes the code
optimized and makes the performance fast. Whenever a variable is declared inside a
program, then the system allocates some memory to a variable. The memory
contains some address number. The variables that hold this address number is
known as the pointer variable.
o The structure is a user-defined data type that allows storing multiple types of data in
a single unit. It occupies the sum of the memory of all members.
o The structure members can be accessed only through structure variables.
o Structure variables accessing the same structure but the memory allocated for each
variable will be different.
What is an array in C?
An Array is a group of similar types of elements. It has a contiguous memory
location. It makes the code optimized, easy to traverse and easy to sort. The size and
type of arrays cannot be changed after its declaration.
scanf(): The scanf() function is used to take input from the user.
What is NULL pointer?
Ans: NULL is used to indicate that the pointer doesn’t point to a valid
location. Ideally, we should initialize pointers as NULL if we don’t know their
value at the time of declaration. Also, we should make a pointer NULL when
memory pointed by it is deallocated in the middle of a program.
When using Call by Value, you are sending the value of a variable as
parameter to a function, whereas Call by Reference sends the address of
the variable. Also, under Call by Value, the value in the parameter is not
affected by whatever operation that takes place, while in the case of Call by
Reference, values can be affected by the process within the function.
What is a stack?
A stack is one form of a data structure. Data is stored in stacks using the
FILO (First In Last Out) approach. At any particular instance, only the top of
the stack is accessible, which means that in order to retrieve data that is
stored inside the stack, those on the upper part should be extracted first.
Storing data in a stack is also referred to as a PUSH, while data retrieval is
referred to as a POP.
Can I use "int" data type to store the value 32768? Why?
No. "int" data type is capable of storing values from -32768 to 32767. To
store 32768, you can use "long int" instead. You can also use "unsigned
int", assuming you don't intend to store negative values.
The most commonly used built-in functions in C are scanf(), printf(), strcpy, strlwr,
strcmp, strlen, strcat, and many more.
All statements written in a program are executed from top to bottom one by one.
Control statements are used to execute/transfer the control from one part of the
program to another depending on the condition.
If-else statement.
o normal if-else statement.
o Else-if statement
o nested if-else statement.
Switch statement.
These 2 functions basically perform the same action, which is to get the
absolute value of the given value. Abs() is used for integer values, while
fabs() is used for floating type numbers. Also, the prototype for abs() is
under <stdlib.h>, while fabs() is under <math.h>
Can we compile a program without main() function?
Yes, we can compile, but it can't be executed.
But, if we use #define, we can compile and run a C program without using the main()
function. For example:
1. #include<stdio.h>
2. #define start main
3. void start() {
4. printf("Hello");
5. }