C And C++ Memory Storage Coding

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 Bug_quesh
B
Bug_quesh
Community Contributor
Quizzes Created: 1 | Total Attempts: 220
| Attempts: 220 | Questions: 30
Please wait...
Question 1 / 30
0 %
0/100
Score 0/100
1.
Which is the only function all C programs must contain? 

Explanation

In C programming, the main() function is the entry point of any program. It is the function that is automatically called when the program starts executing. Therefore, all C programs must contain a main() function. This function is responsible for executing the code and controlling the flow of the program. It typically contains the instructions and logic that need to be executed by the program.

Submit
Please wait...
About This Quiz
C And C++ Memory Storage Coding - Quiz

Do you like coding of  C and C++ and you want to learn more about it?  Let's start this quiz and learn!

2.
Input/output function prototypes and macros are defined in which header file?
 

Explanation

The correct answer is stdio.h. This header file contains the necessary function prototypes and macros for input/output operations in C programming. It includes functions like printf() and scanf() that are used for displaying output and taking input respectively.

Submit
3. If a is an integer variable, a=7/3; will return a value

Explanation

The expression "a=7/3" assigns the value of the division of 7 by 3 to the variable "a". In integer division, any decimal part is truncated, so the result is 2. Therefore, the correct answer is 2.

Submit
4. To print out a and b given below, which of the following printf() statement will you use?
#include<stdio.h>

float a=3.14;
double b=3.14;

Explanation

The correct answer is printf("%f %lf", a, b) because the variable "a" is a float and the variable "b" is a double. The format specifier "%f" is used to print float values and "%lf" is used to print double values.

Submit
5. Which of the following concepts means determining at runtime what method to invoke?

Explanation

Dynamic binding refers to the process of determining at runtime which method to invoke. It allows the program to select the appropriate method based on the actual type of the object, rather than the declared type. This enables polymorphism, where different objects can respond differently to the same method call. Dynamic binding is an essential feature of object-oriented programming languages, as it allows for flexibility and extensibility in the code.

Submit
6. How we can define member function outside the class ?

Explanation

Member functions in C++ can be defined outside the class using the scope resolution operator (::). This allows the definition of the function to be separate from the class declaration, providing better organization and readability of the code. By using the scope resolution operator, the function is associated with the specific class and can access its private members.

Submit
7. Which of the following concept of oops allows compiler to insert arguments in a function call if it is not specified?

Explanation

Default arguments in object-oriented programming allow the compiler to automatically insert arguments in a function call if they are not specified by the programmer. This feature is useful when a function has parameters that have default values assigned to them. If the programmer does not provide a value for a particular parameter, the compiler will automatically use the default value defined in the function declaration. This allows for more flexibility and convenience when calling functions, as it reduces the need for explicitly specifying all arguments in every function call.

Submit
8. What will be the output of the program ?
#include<stdio.h>

int main()
{
    int k=1;
    printf("%d == 1 is" "%s\n", k, k==1?"TRUE":"FALSE");
    return 0;
}

Explanation

The program will output "1 == 1 is TRUE". This is because the variable "k" is initialized to 1, and the expression "k==1" evaluates to true. Therefore, the program will print "TRUE" as the output.

Submit
9. Can you combine the following two statements into one?
char *p;
p = (char*) malloc(100);

Explanation

The correct answer is "char *p = (char*)malloc(100)". This is because it correctly combines the two statements into one. The first statement declares a pointer variable "p" of type char. The second statement allocates memory of size 100 using malloc and assigns the address of the allocated memory to the pointer variable "p".

Submit
10. Relational operators cannot be used on:

Explanation

Relational operators, such as greater than (>), less than (

Submit
11. Which among the following is NOT a logical or relational operator?

Explanation

The operator "=" is not a logical or relational operator. It is the assignment operator used to assign a value to a variable. Logical and relational operators are used to compare values or check conditions, such as "!=" (not equal to), "||" (logical OR), and "==" (equal to).

Submit
12. What is the output of this C code?  void main()    {        int x = 4.3 % 2;        printf("Value of x is %d", x);    } 

Explanation

The code will result in a compile time error. In C, the modulus operator (%) can only be used with integer operands. In this code, the variable x is declared as an integer, but the value 4.3 is a floating-point number. Therefore, the code will not compile because the modulus operator cannot be used with a floating-point operand.

Submit
13. What does the client module import?

Explanation

The client module imports the interface.

Submit
14. Which of the following operations can be performed on the file "NOTES.TXT" using the below code?
FILE *fp;
fp = fopen("NOTES.TXT", "r+");

Explanation

The code snippet opens the file "NOTES.TXT" with the mode "r+" which allows both reading and writing operations on the file. Therefore, the operations that can be performed on the file using this code are reading and writing.

Submit
15. What is output for  the following code:#include <stdio.h>int main(){static int a = 3;printf("%d", a --);return 0;} 

Explanation

The code snippet declares a static integer variable "a" with an initial value of 3. The printf statement prints the value of "a" and then decrements it by 1. Since the decrement operator "--" is placed after the variable, the value of "a" is printed before it is decremented. Therefore, the output of the code will be 3.

Submit
16. How many types of constructor are there in C++?

Explanation

In C++, there are three types of constructors. The first type is the default constructor, which is automatically called when an object is created without any arguments. The second type is the parameterized constructor, which allows us to initialize the object with specific values. The third type is the copy constructor, which is used to create a new object by copying the values of an existing object. Therefore, the correct answer is 3.

Submit
17. Which of the following statement is correct?

Explanation

A reference is stored on the stack because when a variable is declared and assigned a value, the reference to that variable is stored on the stack. The stack is a region of memory that is used for local variables and function calls. When a function is called, the variables and their references are pushed onto the stack, and when the function returns, they are popped off the stack. Therefore, a reference is stored on the stack.

Submit
18. Which of the following statement is correct?

Explanation

The correct statement is that strcmp(s1, s2) returns 0 if s1 is equal to s2. This is because strcmp() is a function in C programming language that compares two strings. It returns a value less than 0 if the first string (s1) is greater than the second string (s2), a value greater than 0 if the first string is less than the second string, and 0 if the strings are equal. Therefore, the correct answer is that strcmp(s1, s2) returns 0 if s1 is equal to s2.

Submit
19. What happens when a class with parameterized constructors and having no default constructor is used in a program and we create an object that needs a zero-argument constructor?

Explanation

When a class with parameterized constructors and no default constructor is used in a program, it means that the class requires specific arguments to be passed during object creation. If we try to create an object of this class without providing the required arguments, a compile-time error will occur. This is because the compiler cannot find a suitable constructor to create the object, resulting in a compile-time error.

Submit
20. #include is called

Explanation

The given correct answer is "Preprocessor directive" because the "#include" statement is a preprocessor directive in C and C++ programming languages. Preprocessor directives are instructions that are processed by the preprocessor before the compilation of the code. The "#include" directive is used to include header files in the code, allowing the use of functions and definitions from those files in the program. Therefore, the statement "#include is called" is referring to the preprocessor directive that includes external files in the code.

Submit
21.
For 16-bit compiler allowable range for integer constants is ________? 

Explanation

The correct answer is -32768 to 32767. This is because a 16-bit compiler can represent integers using 16 bits, which allows for a total of 2^16 = 65536 different values. However, one bit is used to represent the sign of the integer, leaving 15 bits to represent the magnitude. With 15 bits, the range of representable values is -2^15 to 2^15 - 1, which is equivalent to -32768 to 32767.

Submit
22. A .............. is an alias or synonym for another variable.

Explanation

A reference is an alias or synonym for another variable. In other words, it is a way to refer to the same memory location or data as another variable, but with a different name. By using a reference, we can access and manipulate the value of the original variable through the reference variable. This can be useful in situations where we want to have multiple names for the same data or when we want to pass variables by reference to functions.

Submit
23. Which is more memory efficient ?

Explanation

A union is more memory efficient compared to a structure because it allows different variables to share the same memory space. In a structure, each variable has its own memory space, leading to potential wastage of memory. However, in a union, all variables share the same memory space, which reduces memory consumption. This is particularly useful when only one variable is accessed at a time, as it allows for efficient memory utilization.

Submit
24. Which of the following is the correct order if calling functions in the below code?a = f1(23, 14) * f2(12/4) + f3();

Explanation

The correct answer is "Order may vary from compiler to compiler." In this code, the functions f1, f2, and f3 are being called in an expression to calculate the value of variable a. The order in which these functions are executed can vary depending on the compiler being used. Different compilers may have different rules or optimizations that determine the order of function execution. Therefore, the order of calling functions cannot be determined definitively and may vary.

Submit
25. Cout is a/an __________ .

Explanation

The correct answer is "object" because "cout" is an object of the "ostream" class in C++. It is used to display output on the console.

Submit
26. What are mandatory parts in function declaration?

Explanation

The mandatory parts in a function declaration are the return type and the function name. These two components are essential in defining a function in any programming language. The return type specifies the type of value that the function will return, while the function name is used to identify and call the function in the code. The parameters, on the other hand, are optional and may or may not be included in the function declaration depending on the requirements of the program.

Submit
27.
What is the size of an int data type?
 

Explanation

The size of an int data type depends on the system or compiler being used. Different systems or compilers may allocate different amounts of memory for an int variable. Therefore, the size cannot be determined without considering the specific system or compiler in use.

Submit
28.  What will be printed for the below statement?
#include<stdio.h>

main()
{
   printf("%d",strcmp("strcmp()","strcmp()"));
}

Explanation

The code is using the strcmp() function to compare two strings "strcmp()" and "strcmp()". The strcmp() function returns 0 if the two strings are equal. Therefore, the printf() statement will print 0.

Submit
29. Which is not a storage class? 

Explanation

The storage classes in C programming language are auto, register, static, and extern. Struct is not a storage class; it is a keyword used to define a user-defined data type that groups different types of variables together.

Submit
30. Which of the following are available only in the class hierarchy chain?

Explanation

Protected data members are available only in the class hierarchy chain. This means that they can be accessed by the derived classes that inherit from the base class, but not by objects of the base class or objects of other unrelated classes. Protected data members provide a level of encapsulation and allow derived classes to have access to certain data that is not accessible to the outside world.

Submit
View My Results

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

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

  • Current Version
  • Mar 21, 2023
    Quiz Edited by
    ProProfs Editorial Team
  • Feb 13, 2017
    Quiz Created by
    Bug_quesh
Cancel
  • All
    All (30)
  • Unanswered
    Unanswered ()
  • Answered
    Answered ()
Which is the only function all C programs must contain?
Input/output function prototypes and macros are defined in which...
If a is an integer variable, a=7/3; will return a value
To print out a and b given below, which of the following printf()...
Which of the following concepts means determining at runtime what...
How we can define member function outside the class ?
Which of the following concept of oops allows compiler to insert...
What will be the output of the program ?#include<stdio.h> ...
Can you combine the following two statements into one?char *p; ...
Relational operators cannot be used on:
Which among the following is NOT a logical or relational operator?
What is the output of this C code?  void main()   ...
What does the client module import?
Which of the following operations can be performed on the file...
What is output for  the following code:#include...
How many types of constructor are there in C++?
Which of the following statement is correct?
Which of the following statement is correct?
What happens when a class with parameterized constructors and having...
#include is called
For 16-bit compiler allowable range for integer constants is ________?
A .............. is an alias or synonym for another variable.
Which is more memory efficient ?
Which of the following is the correct order if calling functions in...
Cout is a/an __________ .
What are mandatory parts in function declaration?
What is the size of an int data type?
 What will be printed for the below statement?...
Which is not a storage class? 
Which of the following are available only in the class hierarchy...
Alert!

Advertisement