All Exams Test series for 1 year @ ₹349 only
Question

What will the output of the given program be?
#include<stdio.h>
main()
{
printf(6+"Hello World\n");
}

The correct answer is

World

Solution:

The given program is:

#include<stdio.h>
main()
{
    printf(6+"Hello World\n");
}

In C language, a string is stored as a sequence of characters, and the name of the string represents the address of its first character.

So,

"Hello World\n"

is the starting address of the string, and

6 + "Hello World\n"

means the pointer moves 6 positions ahead in the string.

Now count the characters:

H(0), e(1), l(2), l(3), o(4), space(5), W(6), o(7), r(8), l(9), d(10)

After moving 6 positions, printing starts from W.

Therefore, the output will be:

\[ \boxed{\text{World}} \]

Was this answer helpful?

Important Questions from Programming in C

  1. Which among the following is a valid string function?

  2. A function which calls itself is called a

  3. Which of the following function sets first n characters of a string to a given character?

  4. Which of the following statement provides an easy way to dispatch execution to different parts of code based on the value of the expression?

  5. Which of the following operators has left to right associativity?

Need Expert Advice?

Start Your Preparation with Prepp Mobile App

Download the app from Google Play & App Store
Download the app from Google Play & App Store
Prepp Mobile App