Tuesday, November 19, 2024
Google search engine
HomeData Modelling & AIAlgorithms Quiz | Sudo Placement : Set 1 | Question 5

Algorithms Quiz | Sudo Placement : Set 1 | Question 5

What will be the output of following C program?

main()
{
char g[] = "neveropen";
printf("%s", g + g[6] - g[8]);
}

(A) neveropen
(B) rneveropen
(C) neveropen
(D) forneveropen

Answer: (A)
Explanation:

char g[] = “neveropen”;  

// g now has the base address string “neveropen”  

// 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 “neveropen”  

printf(“%s”, g + g[6] – g[8]);  // prints neveropen 

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, neveropen 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!

RELATED ARTICLES

Most Popular

Recent Comments