Home » Programming & Data Structure » Programming and data structure miscellaneous » Question

Programming and data structure miscellaneous

Programming & Data Structure

  1. Consider the following C Program.
    #include
    #include
    int main () {
        char* c = “GATECSIT2017”;
        char* p = c;
        printf (“%d”, (int) strlen (c+2[p]–6[p]–1));
        return 0;
    }
    The output of the program is ________.
    1. 1
    2. 2
    3. 3
    4. 5
Correct Option: B

In the given program:
String ⇒ (C + 2[P] - 6[P] - 1)

Let, address ((0[P] = 100) = C)
Strlen (C + 2[P] + 6[P] – 1)
= Strlen (100 + ('T ' – 'I') – 1)
No, putting ACCII value of T and I, then
= Strlen (100 + 11 – 1)
= Strlen (100 + 10)
= Strlen (110) = 2



Your comments will be displayed only after manual approval.