Knowee
Questions
Features
Study Tools

What will be the output of the following C program?#include <stdio.h>int main(){ char star[10]="HelloWorld"; printf("%c\n",star[5]); return 0;}Select one:ErroreWw

Question

What will be the output of the following C program?#include <stdio.h>int main(){ char star[10]="HelloWorld"; printf("%c\n",star[5]); return 0;}Select one:ErroreWw

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

Solution

The output of the given C program will be 'W'.

Here's the step by step explanation:

  1. The program starts with including the standard input-output library in C using #include <stdio.h>.

  2. The main() function is declared which is the entry point of the program.

  3. Inside the main function, a character array star of size 10 is declared and initialized with the string "HelloWorld".

  4. The printf function is used to print the character at the 5th index of the array star. In C, array indexing starts from 0. So, star[5] refers to the 6th character of the string "HelloWorld", which is 'W'.

  5. The program then returns 0 indicating successful termination.

So, the correct answer is 'W'.

This problem has been solved

Similar Questions

What is the output of the C Program?

What will be the output of the following program?

What will be the output of the C program? ans.09119011 Previous Marked for Review Next

What would be the output of the following program?#include <stdio.h>int main( ){int j=1;while (j <= 255){printf ( "%c %d\n ", j, j );j++;}return 0;}ans.

What will be the output of the following program?Note: This question helps in clearing AMCAT exam.12345678910#include <stdio.h>int main() { int c = 0, e = 0; for (e = 0;e < 5; e++) { c++; if (e == 3) break; } printf("%d",c);}

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.