Online Test : C Programming Part II

Approved & Edited by ProProfs Editorial Team
The editorial team at ProProfs Quizzes consists of a select group of subject experts, trivia writers, and quiz masters who have authored over 10,000 quizzes taken by more than 100 million users. This team includes our in-house seasoned quiz moderators and subject matter experts. Our editorial experts, spread across the world, are rigorously trained using our comprehensive guidelines to ensure that you receive the highest quality quizzes.
Learn about Our Editorial Process
| By Neeta Sawant
N
Neeta Sawant
Community Contributor
Quizzes Created: 1 | Total Attempts: 155
Questions: 25 | Attempts: 164

SettingsSettingsSettings
Online Test : C Programming Part II - Quiz

Unit I : Functions


Questions and Answers
  • 1. 

    Any C Program can contain............

    • A.

      Must contain at least one function

    • B.

      Need not contain any function

    • C.

      Needs input data

    • D.

      None of the above

    Correct Answer
    A. Must contain at least one function
    Explanation
    Every C program must contain at least one function because a function is the basic building block of a program in C. It is where the actual code execution takes place. Without a function, there would be no code to execute, and the program would be meaningless. Therefore, it is a requirement for any C program to have at least one function.

    Rate this question:

  • 2. 

    Which of the following is the default parameter passing method?

    • A.

      Call by value

    • B.

      Call by reference

    • C.

      Call by value result

    • D.

      None of the above

    Correct Answer
    A. Call by value
    Explanation
    The default parameter passing method is "Call by value." In this method, a copy of the actual parameter is passed to the function, and any changes made to the parameter inside the function do not affect the original value. This is the most commonly used method as it ensures that the original value remains unchanged.

    Rate this question:

  • 3. 

    A function which calls itself is called.........

    • A.

      Self function

    • B.

      Void function

    • C.

      Recursive function

    • D.

      Static function

    Correct Answer
    C. Recursive function
    Explanation
    A function which calls itself is called a recursive function. This type of function is used to solve problems that can be broken down into smaller, repetitive tasks. The function calls itself with a smaller input each time until it reaches a base case, where it stops calling itself and returns a result. This allows for a more concise and elegant solution to certain problems.

    Rate this question:

  • 4. 

    What will be the output of following code? # include <stdio.h> void show(); void main() { printf("C Programming"); show(); getch(); } void show() { printf("Language"); }

    • A.

      C Programming

    • B.

      C Programming Language

    • C.

      Language

    • D.

      Compile Error

    Correct Answer
    B. C Programming Language
    Explanation
    The code will output "C ProgrammingC Programming Language". This is because the main function first prints "C Programming" using the printf statement, then calls the show function, which prints "Language" using the printf statement. Therefore, the final output will be the combination of both strings.

    Rate this question:

  • 5. 

    What are the types of functions in C language?

    • A.

      Library Funcions

    • B.

      User defined functions

    • C.

      Both the above

    • D.

      None of these

    Correct Answer
    C. Both the above
    Explanation
    The types of functions in C language are library functions and user-defined functions. Library functions are predefined functions that are provided by the C standard library and can be directly used in a program. User-defined functions, on the other hand, are created by the user to perform specific tasks and can be called from within the program. Therefore, the correct answer is "Both the above" as both types of functions exist in C language.

    Rate this question:

  • 6. 

    Which keyword is used to transfer control from a function back to the calling function ?

    • A.

      Switch

    • B.

      Goto

    • C.

      Return

    • D.

      Void

    Correct Answer
    C. Return
    Explanation
    The keyword "return" is used to transfer control from a function back to the calling function. When a function is called, it performs a specific task and then returns a value to the calling function using the "return" keyword. This allows the calling function to continue executing its code after the function call.

    Rate this question:

  • 7. 

    Which method is used in the following function? int &x;

    • A.

      X is passed by value

    • B.

      X is passed by reference

    • C.

      X is declared outside of the function

    • D.

      None of the above

    Correct Answer
    B. X is passed by reference
    Explanation
    The given function declares a variable x of type int and uses the reference symbol "&" to indicate that x is passed by reference. This means that any changes made to x within the function will affect the original value of x outside of the function.

    Rate this question:

  • 8. 

    Which statement is correct about passing by value parameters?

    • A.

      It cannot changee the actual parameter value

    • B.

      It can change the actual parameter value

    • C.

      Psrameter is always read write mode

    • D.

      All of the above

    Correct Answer
    A. It cannot changee the actual parameter value
    Explanation
    Passing by value parameters means that the function receives a copy of the value of the actual parameter. Therefore, any changes made to the parameter within the function do not affect the original value. As a result, the statement "It cannot change the actual parameter value" is correct.

    Rate this question:

  • 9. 

    Which statement is correct about passing by value parameters?

    • A.

      It cannot change the actual parameter value

    • B.

      It can change the actual parameter value

    • C.

      Parameters always read-write mode

    • D.

      None of the above

    Correct Answer
    A. It cannot change the actual parameter value
    Explanation
    Passing by value parameters means that the values of the actual parameters are copied to the formal parameters of a function. Therefore, any changes made to the formal parameters within the function will not affect the original values of the actual parameters. Hence, the statement "It cannot change the actual parameter value" is correct.

    Rate this question:

  • 10. 

    Which of the following is not a storage class in C language?

    • A.

      Auto

    • B.

      Extern

    • C.

      Volatile

    • D.

      Register

    Correct Answer
    C. Volatile
    Explanation
    The correct answer is "volatile". In the C language, "volatile" is not a storage class. The "volatile" keyword is used to indicate that a variable may be modified by external factors outside the control of the program, such as hardware or other threads. It is used to prevent certain optimizations by the compiler that may assume the variable does not change unexpectedly.

    Rate this question:

  • 11. 

    ............. is a group of statements that together perform a specific task

    • A.

      Array

    • B.

      Function

    • C.

      Program

    • D.

      Pointer

    Correct Answer
    B. Function
    Explanation
    A function is a group of statements that together perform a specific task. Functions are reusable blocks of code that can be called multiple times within a program. They are used to break down a complex problem into smaller, manageable tasks, making the code more organized and easier to understand. By encapsulating a set of instructions into a function, it can be executed whenever needed, improving code reusability and maintainability.

    Rate this question:

  • 12. 

    User defined and.......................... functions are types of functions in C programming.

    • A.

      Library

    • B.

      Static

    • C.

      Array

    • D.

      Main

    Correct Answer
    A. Library
    Explanation
    In C programming, user-defined functions and library functions are types of functions. User-defined functions are created by the programmer to perform specific tasks, while library functions are pre-defined functions provided by the C library that can be used to perform common operations. These library functions are already implemented and can be accessed by including the appropriate header files. Therefore, the correct answer is "Library".

    Rate this question:

  • 13. 

    A scope of variable inside a function is called............

    • A.

      Local

    • B.

      Global

    • C.

      Static

    • D.

      None of these

    Correct Answer
    A. Local
    Explanation
    The scope of a variable inside a function is referred to as "local". This means that the variable is only accessible within the specific function where it is defined. Variables declared outside of any functions have a global scope, meaning they can be accessed from anywhere in the code. Static variables have a different purpose, as they retain their value between function calls. Therefore, the correct answer is "Local".

    Rate this question:

  • 14. 

    Printf() and scanf() are examples of ................ type of functions

    • A.

      User defined functions

    • B.

      Library functions

    • C.

      Static functions

    • D.

      Void functions

    Correct Answer
    B. Library functions
    Explanation
    The correct answer is library functions because printf() and scanf() are functions that are provided by the C standard library. Library functions are pre-defined functions that are included in libraries and can be used by programmers to perform common tasks without having to write the code from scratch.

    Rate this question:

  • 15. 

    A/An ...................... is the actual data that we pass to the function parameter

    • A.

      Argument

    • B.

      Values

    • C.

      Parameter

    • D.

      Values

    Correct Answer
    A. Argument
    Explanation
    In programming, an argument is the actual data that we pass to a function parameter. When we call a function, we provide arguments which are the specific values or variables that the function will use to perform its operations. These arguments are then assigned to the corresponding parameters defined in the function's declaration. Therefore, the correct answer is "Argument".

    Rate this question:

  • 16. 

    How many function categories in C programming?

    • A.

      One

    • B.

      Two

    • C.

      Three

    • D.

      Four

    Correct Answer
    D. Four
    Explanation
    There are four function categories in C programming.

    Rate this question:

  • 17. 

    Which type of following function is? float CalArea(float length, float width) { return length*width; }

    • A.

      Function with no argument and no return value

    • B.

      Function with argument and no return value

    • C.

      Function with no argument and with return value

    • D.

      Function with argument and with return value

    Correct Answer
    D. Function with argument and with return value
    Explanation
    The given function "CalArea" takes two arguments, length and width, and returns the product of the two values, which represents the area of a rectangle. Therefore, the function is a "Function with argument and with return value".

    Rate this question:

  • 18. 

    How many storage classes in C programming?

    • A.

      Three

    • B.

      Four

    • C.

      Five

    • D.

      Six

    Correct Answer
    A. Three
    Explanation
    In C programming, there are three storage classes: auto, register, and static. The auto storage class is used for local variables, the register storage class is used for variables that should be stored in a register for faster access, and the static storage class is used for variables that retain their values even after the function call ends. Therefore, the correct answer is three.

    Rate this question:

  • 19. 

    The use of Functions in C programming is/are........

    • A.

      Helps to avoid repeating set of statements many times

    • B.

      Enhance the logical clearity of the program

    • C.

      Helps to avoid repeated programming across programs

    • D.

      All of the above

    Correct Answer
    D. All of the above
    Explanation
    Functions in C programming are used to avoid repeating a set of statements multiple times, enhance the logical clarity of the program, and avoid repeated programming across programs. By encapsulating a set of statements within a function, it can be easily called and reused whenever needed, reducing code duplication and improving code readability. Therefore, all of the given options are valid reasons for using functions in C programming.

    Rate this question:

  • 20. 

    What will be the output of the following program? # include <stdio.h> void test(); void main() { test(); getch(); } test() { printf("Hello"); }  

    • A.

      Hello

    • B.

      Complile time Error

    • C.

      Run time Error

    • D.

      Infinite loop

    Correct Answer
    A. Hello
    Explanation
    The program will output "Hello". The function test() is called in the main() function, which then prints "Hello" using the printf() function.

    Rate this question:

  • 21. 

    Which storage class is used for define local variable within function?

    • A.

      Extern

    • B.

      Register

    • C.

      Auto

    • D.

      Static

    Correct Answer
    C. Auto
    Explanation
    The storage class "auto" is used to define local variables within a function. When a variable is declared as "auto", it is automatically allocated memory when the function is called and deallocated when the function ends. This is the default storage class for local variables, so it doesn't need to be explicitly mentioned.

    Rate this question:

  • 22. 

    Which storage class is used to store variable in the register of the microprocessor if a free register is available?

    • A.

      Auto

    • B.

      Extern

    • C.

      Static

    • D.

      Register

    Correct Answer
    D. Register
    Explanation
    The storage class "register" is used to store variables in the register of the microprocessor if a free register is available. The register storage class is used to optimize the performance of frequently accessed variables by storing them in the fastest memory location of the microprocessor, which is the register. This allows for quicker access and manipulation of the variable, resulting in improved program execution speed.

    Rate this question:

  • 23. 

    A function .............. tells the compiler about a function name and how to call the function 

    • A.

      Definition

    • B.

      Declaration

    • C.

      Function calling

    • D.

      None of these

    Correct Answer
    B. Declaration
    Explanation
    A function declaration tells the compiler about a function name and how to call the function. It provides the function's name, return type, and parameter types, but does not contain the function's implementation. This allows the compiler to know that the function exists and how it should be called, enabling proper compilation and linking of the code.

    Rate this question:

  • 24. 

    What is Function?

    • A.

      Function is a block of statements that perform some specific task

    • B.

      Function is the fundamental modular unit.

    • C.

      Function is a block of code has a name and it is reusable.

    • D.

      All of the above

    Correct Answer
    D. All of the above
    Explanation
    The correct answer is "All of the above". This is because all three statements accurately describe what a function is. A function is a block of statements that perform a specific task, it is the fundamental modular unit, and it is a block of code that has a name and is reusable. Therefore, all of the given options are correct explanations of what a function is.

    Rate this question:

  • 25. 

    ....................... method copies the address of an argument into the formal parameter.

    • A.

      Call by value

    • B.

      Call by reference

    • C.

      Call by variable

    • D.

      None of the above

    Correct Answer
    A. Call by value
    Explanation
    In call by value method, the address of the argument is not copied into the formal parameter. Instead, a copy of the argument's value is made and passed to the formal parameter. Therefore, the correct answer is not "Call by value".

    Rate this question:

Quiz Review Timeline +

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

  • Current Version
  • Feb 17, 2023
    Quiz Edited by
    ProProfs Editorial Team
  • Apr 16, 2020
    Quiz Created by
    Neeta Sawant
Back to Top Back to top
Advertisement
×

Wait!
Here's an interesting quiz for you.

We have other quizzes matching your interest.