Answer is NING.
how....? i am not getting. can any one explain please....?

‪#‎inclde‬<stdio.h>
void main()
{
    printf(2+"GOOD EVENING"+6);
    getch();
}

Edited 3 Years Ago by deceptikon: Changed to discussion thread

It skips the first 6+2 characters/bytes of the string by moving the pointer (since the string's value is stored in contiguous memory locations) => GOOD EVENING.

Edited 3 Years Ago by TheApex

Not sure where you got that syntax from. It is truncating 8 characters from your string though. And it works on 2 different compilers.

Edited 3 Years Ago by tinstaafl

"GOOD EVENING" is an array of characters. If you take any array or pointer and write p + i, you get a pointer pointing to the address that's i elements after the location that p points to. So in case of an array, arr + i (or i + arr - order doesn't matter) produces a pointer to the element of the array arr at index i.

So 2 + "GOOD EVENING" produces a pointer that points to the second O in GOOD. Adding 6 to that moves the pointer 6 further to the right, producing a pointer that points to the first N in EVENING - same as if you had written "GOOD EVENING" + 8. So you pass a pointer to that N to printf and printf then prints all characters starting at that pointer until the end of the string. So that's why you get NING.

This question has already been answered. Start a new discussion instead.