Accenture Placement: Sample Questions 3 - 5 of 9
Get unlimited access to the best preparation resource for competitive exams : get questions, notes, tests, video lectures and more- for all subjects of your exam.
Question 3
Explanation
Extern is a key word in C that indicates the scope of a variable or function.
extern int i;
Extern int i | Declare the extern integer i |
i = 20 | Integer value is 20 |
Printf ( “% d” i) | i is available in any other program with memory space allocated for it. During linking the linker searches for the definition of i. So, it is not found the linker flags an error. |
So generate Linker Error: Undefined symbol ‘_i’
Question 4
Describe in Detail Essay▾
main()
{
int i=3;
switch (i)
{
default:printf(“zero”);
case 1:printf(“one”);
break;
case 2:printf ( “two” );
break;
case 3:printf ( “three” );
break;
}
}
Explanation
Given i = 3
Int i = 3 | Given integer variable i = 3 |
| In this switch condition case 3 (i = 3) is selected As there is a break statement after it, it comes out of the switch |
So, answer is three.
Question 5
Explanation
- In a program
Table Shows the Program int const ⚹ p = 5; Pointer to constant integer printf ( “% d” ++ (⚹ p) ) ; We tried to change constant integer value - But constant value can՚t change
- So, the answer is Compiler error: Cannot modify a constant value.