2 2 votes Consider the following C program:What is the output printed by the above program?____ // gateastra.com Programming in C programming-in-c pointers + – Lohith_Papineni 262 views answer comment Share Follow Print 0 reply Please log in or register to add a comment.
1 1 vote The output of the program is 4. In the test function, the pointer p starts at the beginning of the array {4, 8, 5, 13}. The while(*p++ != 13); loop uses the post-increment operator, which means it first retrieves the value at the current address to check if it's 13 and then immediately moves the pointer to the next memory address. When the loop finally encounters the value 13, the condition becomes false and the loop stops, but the pointer p still performs that final increment. This leaves p pointing exactly four positions ahead of the starting pointer a (one position past the 13). Therefore, the pointer subtraction p - a calculates the distance between these two addresses, which is 4. VIPIN_CHANDRA answered Apr 10 VIPIN_CHANDRA comment Share Follow 0 reply Please log in or register to add a comment.