Important Introduction to Programming Short Questions
Chapter: 14
Question 1:
What is a function prototype?
Answer:
A function prototype is a declaration of a function that specifies the function's name, return type, and parameters, helping the compiler understand how to call the function.
Chapter: 14
Question 2:
How does the islower function work?
Answer:
The islower function checks if a character is a lowercase letter. If true, it returns a non-zero value; otherwise, it returns zero.
Chapter: 14
Question 3:
What does cin >> *num do in a function receiving a pointer?
Answer:
cin >> *num reads a value from the input and stores it at the memory location pointed to by num.
Chapter: 14
Question 4:
Why should pointers be initialized with NULL?
Answer:
Pointers should be initialized with NULL to indicate they do not point to any valid memory location, reducing the risk of accidental dereferencing.
Chapter: 14
Question 5:
How does pointer arithmetic work?
Answer:
Pointer arithmetic involves manipulating the memory address stored in a pointer, such as incrementing the pointer to point to the next memory location of the same data type.
Chapter: 15
Question 6:
What does the name of an array represent in C?
Answer:
The name of an array in C represents a constant pointer containing the memory address of the first element of the array.
Chapter: 15
Question 7:
Can the name of an array be reassigned to point to another memory location?
Answer:
No, the name of an array is a constant pointer and always points to the first element of the array.
Chapter: 15
Question 8:
What is the key difference between an array name and a pointer variable?
Answer:
An array name is a constant pointer that cannot be reassigned, while a pointer variable can point to any memory address.
Chapter: 15
Question 9:
How do you access the fourth element of an array using a pointer?
Answer:
You can access the fourth element of an array using a pointer with the expression *(yptr + 3), assuming yptr points to the first element.
Chapter: 15
Question 10:
What happens when you increment a pointer in C?
Answer:
When you increment a pointer, it moves to the next memory location based on its data type. For example, if it's an integer pointer, it will move to the next integer location.