1.
Any C Program can contain............
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.
2.
Which of the following is the default parameter passing method?
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.
3.
A function which calls itself is called.........
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.
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");
}
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.
5.
What are the types of functions in C language?
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.
6.
Which keyword is used to transfer control from a function back to the calling function ?
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.
7.
Which method is used in the following function?
int &x;
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.
8.
Which statement is correct about passing by value parameters?
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.
9.
Which statement is correct about passing by value parameters?
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.
10.
Which of the following is not a storage class in C language?
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.
11.
............. is a group of statements that together perform a specific task
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.
12.
User defined and.......................... functions are types of functions in C programming.
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".
13.
A scope of variable inside a function is called............
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".
14.
Printf() and scanf() are examples of ................ type of 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.
15.
A/An ...................... is the actual data that we pass to the function parameter
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".
16.
How many function categories in C programming?
Correct Answer
D. Four
Explanation
There are four function categories in C programming.
17.
Which type of following function is?
float CalArea(float length, float width)
{
return length*width;
}
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".
18.
How many storage classes in C programming?
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.
19.
The use of Functions in C programming is/are........
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.
20.
What will be the output of the following program?
# include <stdio.h>
void test();
void main()
{
test();
getch();
}
test()
{
printf("Hello");
}
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.
21.
Which storage class is used for define local variable within function?
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.
22.
Which storage class is used to store variable in the register of the microprocessor if a free register is available?
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.
23.
A function .............. tells the compiler about a function name and how to call the function
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.
24.
What is Function?
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.
25.
....................... method copies the address of an argument into the formal parameter.
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".