C/C++ Programming Fundamentals
Test your knowledge of C and C++ programming concepts including constructors, pointers, operators, functions, memory management, and language fundamentals.
Questions
Variables with names that describe the data stored at that particular memory location are called as
- identifiers
- constant variables
- floating point variables
- mnemonic variables
What is the value of x when the below code segment is executed? int main() { int x , *z ; x = 10 ; z = &x ; x = 20 ; *z = 10 ; }
- 10
- 20
- Compilation Error
- RuntimeError
We need to have a structure day of type date which has the following values. date day = {17,2,2011}; Will the following Structure declaration Correct? struct date { int mm ; int dd ; date year ; }day;
- True
- False
What will be output if you will Execute following code? #include<stdio.h> #include<conio.h> void main() { char c=-'a'; printf("%d",c); }
- 65
- -65
- 97
- -97
- CompilationError
Which of the following can be used to initialize a newly declared Variable from an existing variable?
- Virtual Function
- Namespaces
- copy constructor
- None of the Above
The inserting of the code of a called function at the point where The function gets called is achieved by using
- Inline functions
- virtual functions
- Both A and B
- None of the Above
What the following program is executed? void main() { void ptr = (void) malloc(sizeof(void)); ptr++ ; }
- CompilationFails
- Will Throw RunTime Error But Code will get Compiled
- Throws Linker Error
- All the above statements are invalid
What happens when the following code segment is Validated? int x = 20; Int main() { int x ; x = 10 ; return x ; }
- Complies Successfully
- Error Due to Duplicate Variables.
- RunTime Error
- Executes Successfully
The output of operation 20%3 is
- 6
- 2
- 1
- 4
What will be the output of the following code? #include<stdio.h>
- 6
- 7
- 8
- 9
- CompilationError
What will be the output of the following code? #include<stdio.h> int main() { int num,a=5; num=-a--; printf("%d %d",num,a); }
- 5,4
- -4,4
- -5,4
- -4,5
- Compilation Error
setprecision requires the header file
- stdlib.h
- iomanip.h
- console.h
- conio.h
If char catname[15]; , which of the following is valid?
- catname[15] = "Millie";
- catname = "Millie";
- catname[ ] = "Millie";
- None are Valid
Variables with names that describe the data stored at that particular memory location are called as
- identifiers
- constant variables
- floating point variables
- mnemonic variables
What happens when the following code segment is Validated? int x = 20; Int main() { int x ; x = 10 ; return x ; }
- Complies Successfully
- Error Due to Duplicate Variables.
- RunTime Error
- Executes Successfully
What is the value of x when the below code segment is executed? int main() { int x , *z ; x = 10 ; z = &x ; x = 20 ; *z = 10 ; }
- 10
- 20
- Compilation Error
- RuntimeError
Which of the following statements are correct?
- Relational and equality operators evaluate their operands to produce a true or false result.
- The equality operators have the same level of precedence And associate right to left.
- Relational operators all have the same level of precedence And associate right to left.
- The precedence of relational operators is at a lower level Than the precedence of the equality operators.
Which of the following statements are correct about Function prototypes?
- It resembles the header Of the function definition
- It tells the compiler the Names of the parameters
- It must be declared before its corresponding functions can be utilized
- All the above are incorrect
Which of the following will occur when trying to validate the below code Segment? #define <iostream.h> #define <GetSquareOfx.hpp> // GetSquareOfx function-prototype has the following defn // int GetSquareOfx(int) ; Int main() { int x =5 ; Cout << GetSquareOfx() ; return x ; }
- Syntax Error
- Linker Error
- Runtme Error
- No Error, It will be run successfully
Which of the following can be used to initialize a newly declared Variable from an existing variable?
- Virtual Function
- Namespaces
- copy constructor
- None of the Above