Sunday, September 7, 2025
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

Dominic
32271 POSTS0 COMMENTS
Milvus
82 POSTS0 COMMENTS
Nango Kala
6644 POSTS0 COMMENTS
Nicole Veronica
11808 POSTS0 COMMENTS
Nokonwaba Nkukhwana
11871 POSTS0 COMMENTS
Shaida Kate Naidoo
6755 POSTS0 COMMENTS
Ted Musemwa
7030 POSTS0 COMMENTS
Thapelo Manthata
6705 POSTS0 COMMENTS
Umr Jansen
6721 POSTS0 COMMENTS