C Programming - Strings - Discussion

Discussion Forum : Strings - Find Output of Program (Q.No. 24)
24.
What will be the output of the program ?
#include<stdio.h>

int main()
{
    printf(5+"IndiaBIX\n");
    return 0;
}
Error
IndiaBIX
BIX
None of above
Answer: Option
Explanation:

printf(5+"IndiaBIX\n"); In the printf statement, it skips the first 5 characters and it prints "BIX"

Discussion:
4 comments Page 1 of 1.

Gayathri said:   7 years ago
@Vikram Meena.

We have to use cout instead of printf in c++ and cin instead of scanf().

Vikram meena said:   7 years ago
How can we use printf() statement in c++?

Asish said:   8 years ago
In printf(), 5+"indiaBix" is given that means you have to print the 5th char in the given string. a[0] is I and a[5] is B so you have to print on the o/p screen that Bix.

Niteesh said:   1 decade ago
printf() return base address.assume the the base address of indiabix is 100.when the base address is returned it prints till \0.so when we increment by 5 the base address becomes 105 which is B in the given string.so it prints from B to null character

Post your comments here:

Your comments will be displayed after verification.