Languages-C & C Plus Plus [3i Infotech Placement]: Sample Questions 168 - 170 of 354
Glide to success with Doorsteptutor material for competitive exams : get questions, notes, tests, video lectures and more- for all subjects of your exam.
Question 168
Explanation
- Scope Resolution operator (::)
- Pointer to member operator (. ⚹)
- Member Access or Dot operator (.)
- Ternary or Conditional operator (? :)
- Object size operator (sizeof)
- Object type operator (typeid)
Question 169
Explanation
- In a program,
Table Showing the Program extern int i; Extern declaration specifies that the variable i is defined somewhere else. i = 20; printf ( “% d” sizeof (i) ) ;
The compiler passes the external variable to be resolved by the linker. So compiler doesn՚t find an error.
- During linking the linker searches for the definition of i.
- Since it is not found the linker flags an error
Question 170
Question MCQ▾
What will be the result of the following program?
char ⚹gxxx ()
{
static char xxx[1024];
return xxx;
}
main ()
{
char ⚹g =“string”;
strcpy (gxxx (), g);
g =gxxx ();
strcpy (g, “oldstring” );
printf ( “The string is:%s” gxxx () );
}
Choices
Choice (4) | |
---|---|
a. | Run time error/Core dump |
b. | The string is: Oldstring |
c. | Syntax error during compilation |
d. | The string is: String |
Answer
b.Explanation
- In the program
|
|
char ⚹ g = “string” ; |
|
strcpy (gxxx () , g) ; |
|
g = gxxx () ; |
|
strcpy (g, “oldstring” ) ; |
|
printf ( “The string is:% s” gxxx () ) ; |
|