Knowee
Questions
Features
Study Tools

What will be the output of the following code?#include <stdio.h>int main() {    char str[] = "ABCDE";    printf("%c\n", str[2] + 3);    return 0;}

Question

What will be the output of the following code?#include <stdio.h>int main() {    char str[] = "ABCDE";    printf("%c\n", str[2] + 3);    return 0;}

🧐 Not the exact question you are looking for?Go ask a question

Solution

The output of the code will be 'F'.

Explanation:

  1. The code declares a character array str[] with the string "ABCDE".
  2. The printf function is used to print the character at index 2 of the array str[], which is 'C'.
  3. The ASCII value of 'C' is 67. The code adds 3 to this ASCII value, resulting in 70.
  4. The ASCII value 70 corresponds to the character 'F'.
  5. Therefore, 'F' is printed as the output.

This problem has been solved

Similar Questions

What will be the output of the following program?

What will be the output of the following C code?

What will be the output of the following C++ code?

What is the output of the following code in Python?

What will print out when the following code runs?

1/4

Upgrade your grade with Knowee

Get personalized homework help. Review tough concepts in more detail, or go deeper into your topic by exploring other relevant questions.