Quiz 5 - Functions And Pointers

Reviewed by Editorial Team
The ProProfs editorial team is comprised of experienced subject matter experts. They've collectively created over 10,000 quizzes and lessons, serving over 100 million users. Our team includes in-house content moderators and subject matter experts, as well as a global network of rigorously trained contributors. All adhere to our comprehensive editorial guidelines, ensuring the delivery of high-quality content.
Learn about Our Editorial Process
| By Aamirakbar
A
Aamirakbar
Community Contributor
Quizzes Created: 1 | Total Attempts: 284
| Attempts: 284 | Questions: 10
Please wait...
Question 1 / 10
0 %
0/100
Score 0/100
1. The operator used to declare a pointer variable is 

Explanation

The correct answer is * because in C and C++, the asterisk (*) symbol is used to declare a pointer variable. The asterisk is placed before the variable name to indicate that it is a pointer variable, which stores the memory address of another variable.

Submit
Please wait...
About This Quiz
Quiz 5 - Functions And Pointers - Quiz

Quiz 5 covers fundamental concepts of functions and pointers in C programming, including pointer declaration, address storage, and variable passing methods.

Personalize your quiz and earn a certificate with your name on it!
2. Variable passing by reference is achieved by using pointers.

Explanation

Variable passing by reference is achieved by using pointers. In programming, passing by reference means that a reference to the original variable is passed to a function, allowing the function to directly modify the original variable. Pointers are used to achieve this behavior in many programming languages. By passing the memory address of a variable, the function can access and modify the original variable, rather than creating a copy. Therefore, the statement that variable passing by reference is achieved by using pointers is true.

Submit
3. Pointer is a special kind of a variable which is used to store _______ of a variable

Explanation

A pointer is a special kind of variable that is used to store the address of another variable. By storing the address, the pointer allows us to indirectly access and manipulate the value of the variable it points to. This is useful in situations where we need to pass variables by reference or dynamically allocate memory. Therefore, the correct answer is "address".

Submit
4. What does the following mean?int *ptr, p;

Explanation

This statement declares two variables, ptr and p. The declaration "int *ptr" means that ptr is a pointer to an integer. On the other hand, the declaration "p" does not have any asterisk (*) before it, indicating that it is not a pointer. Therefore, the correct answer is that ptr is an integer pointer, while p is not a pointer.

Submit
5. Passing by value means an exact copy of the variable is created and the value is assigned to it.

Explanation

Passing by value means that when a variable is passed as an argument to a function, a copy of the variable is created and the value of the original variable is assigned to it. This means that any changes made to the copy within the function will not affect the original variable. Therefore, the statement is true.

Submit
6. Char data type uses _____ byte (s), int data type uses _____ byte (s) and float uses _____ byte (s)

Explanation

The correct answer is 1, 2, 4. The char data type uses 1 byte, the int data type uses 2 bytes, and the float data type uses 4 bytes.

Submit
7. A pointer is

Explanation

A pointer is a variable that stores the address of another variable. Pointers are used to indirectly access and manipulate data stored in memory. By storing the address of a variable, pointers allow for efficient memory management and the ability to pass variables by reference. Therefore, the correct answer is "A variable that stores the address of other variable."

Submit
8. Suppose a variable x has  an address fff0. declaring a pointer and assigning address of x is as follow.int *p = &x;printf("address of x = %d", *p);the output will be [address of x = fff0] stored in pointer p?

Explanation

The output will not be "[address of x = fff0] stored in pointer p". The output will be the value stored at the address pointed to by pointer p, which is the value of variable x. In this case, it will be the address of x, not the value of x itself.

Submit
9. Choose the best answerPrior to using a pointer variable 

Explanation

Prior to using a pointer variable, it is necessary to both declare and initialize it. Declaring a pointer variable means specifying its data type and name, while initializing it means assigning it a memory address to point to. If a pointer is not declared, it cannot be used in the program. Similarly, if it is not initialized, it does not have a valid memory address to point to, leading to potential errors or undefined behavior when trying to access the memory it points to. Therefore, both declaring and initializing a pointer variable are important steps before using it.

Submit
10. #include<stdio.h>void f(){    printf("hello");}void main(){   f();}the code above has an error.

Explanation

The code provided does not have any errors. It includes the necessary header file, defines a function "f()" that prints "hello", and calls the function "f()" in the main function. Therefore, the correct answer is False.

Submit
View My Results

Quiz Review Timeline (Updated): Mar 30, 2023 +

Our quizzes are rigorously reviewed, monitored and continuously updated by our expert board to maintain accuracy, relevance, and timeliness.

  • Current Version
  • Mar 30, 2023
    Quiz Edited by
    ProProfs Editorial Team
  • Nov 19, 2014
    Quiz Created by
    Aamirakbar
Cancel
  • All
    All (10)
  • Unanswered
    Unanswered ()
  • Answered
    Answered ()
The operator used to declare a pointer variable is 
Variable passing by reference is achieved by using pointers.
Pointer is a special kind of a variable which is used to store _______...
What does the following mean?int *ptr, p;
Passing by value means an exact copy of the variable is created and...
Char data type uses _____ byte (s), int data type uses _____ byte (s)...
A pointer is
Suppose a variable x has  an address fff0. declaring a pointer...
Choose the best answerPrior to using a pointer variable 
#include<stdio.h>void f(){   ...
Alert!

Advertisement