ЁЯУв Too many exams? DonтАЩt know which one suits you best? Book Your Free Expert ЁЯСЙ call Now!


    Question

    Consider the following C code: #include

    #include int main() { ┬а ┬а char* text = "The quick brown fox jumps over the lazy dog."; ┬а ┬а char* pattern = "fox"; ┬а ┬а char* result = strstr(text, pattern); ┬а ┬а if (result != NULL) { ┬а ┬а ┬а ┬а printf("%ld\n", result - text); // Print index ┬а ┬а } else { ┬а ┬а ┬а ┬а printf("-1\n"); ┬а ┬а } ┬а ┬а return 0; } What will be the output of this program?
    A 16 Correct Answer Incorrect Answer
    B 17 Correct Answer Incorrect Answer
    C 18 Correct Answer Incorrect Answer
    D 19 Correct Answer Incorrect Answer
    E -1 Correct Answer Incorrect Answer

    Solution

    Correct Answer: A (Indices: T-0, h-1, e-2, ' '-3, q-4, u-5, i-6, c-7, k-8, ' '-9, b-10, r-11, o-12, w-13, n-14, ' '-15, f-16. So 'fox' starts at index 16.)

    Practice Next
    More IT Operating System Questions
    ask-question