Algorithms Quiz | Sudo Placement : Set 1 | Question 5

What will be the output of following C program?
main()
{
char g[] = "zambiatek";
printf("%s", g + g[6] - g[8]);
}
(A) zambiatek
(B) rzambiatek
(C) zambiatek
(D) forzambiatek
Answer: (A)
Explanation:
char g[] = “zambiatek”; // g now has the base address string “zambiatek” // g[6] is ‘o’ and g[1] is ‘e’. // g[6] – g[1] = ASCII value of ‘o’ – ASCII value of ‘e’ = 8 // So the expression g + g[6] – g[8] becomes g + 8 which is // base address of string “zambiatek” printf(“%s”, g + g[6] – g[8]); // prints zambiatek
Hence, option (A) is correct
Quiz of this Question
Whether you’re preparing for your first job interview or aiming to upskill in this ever-evolving tech landscape, zambiatek Courses are your key to success. We provide top-quality content at affordable prices, all geared towards accelerating your growth in a time-bound manner. Join the millions we’ve already empowered, and we’re here to do the same for you. Don’t miss out – check it out now!



