Question 3762 – UGC NET CS 2015 Jun- paper-2
May 9, 2024Software-Engineering
May 10, 2024Question 3814 – UGC NET CS 2015 Jun- paper-2
What is the output of the following program?
(Assume that the appropriate preprocessor directives are included and there is no syntax error)
main( )
{
char S[ ] = “ABCDEFGH”;
printf (“%C”, *(&S[3]));
printf (“%s”, S+4);
printf (“%u”, S);
/* Base address of S is 1000 */
}
Correct Answer: D
Question 11 Explanation:
Step-1: String is stored in appropriate location is
Step-2: printf (“%C”, *(&S[3]));
This statement will print character ‘D’
(&S[3]) → Will print address of index 3
*(&S[3]) → will print value in index 3. The value is nothing but ‘D’.
Step-3: printf (“%s”, S+4); /* will print characters ‘EFGH’ */
Because previous S value index position is 3. Now we are performing +4 operations. It will print EFGH. we are given escape sequence is String.
Step-4: printf (“%u”, S); → It will print address of S. The base address given as S is 1000.
Step-2: printf (“%C”, *(&S[3]));
This statement will print character ‘D’
(&S[3]) → Will print address of index 3
*(&S[3]) → will print value in index 3. The value is nothing but ‘D’.
Step-3: printf (“%s”, S+4); /* will print characters ‘EFGH’ */
Because previous S value index position is 3. Now we are performing +4 operations. It will print EFGH. we are given escape sequence is String.
Step-4: printf (“%u”, S); → It will print address of S. The base address given as S is 1000.
ABCDEFGH1000
CDEFGH1000
DDEFGHH1000
DEFGH1000
Subscribe
Login
0 Comments