+ 1

Please explain, why I m getting different output each time I run this program.

#include<stdio.h> int main( ) { printf(2+"superman"); //or printf("superman"+2) return 0; } Also when I replace 2 to any other number (say 1) it shows nothing in output. Why ???

23rd Dec 2018, 4:38 PM
Ravindra
Ravindra - avatar
3 Réponses
+ 4
Try it more than 1 time to see "uperman" when we replace 2 by 1 because I got that result It actually skips the specific number of letters And when you replace 2 by 10 or something more than the lenght of the string it displays nothing And an important thing you missed semicolon in the second printf() Many says the result in C code playground displays "No Output", I don't know what is the problem with it
23rd Dec 2018, 5:03 PM
deeyae
deeyae - avatar
+ 2
Yes Mr Adithya, actually I was trying this in C code playground and it shows different output each time And also when I have replace 2 by 6 (which is not more than its length) it shows "No output". But if u can please explain its working I mean why it is skipping
24th Dec 2018, 4:38 AM
Ravindra
Ravindra - avatar
+ 1
I dont get the same behaviour as you. I see "perman" printed on screen.
23rd Dec 2018, 4:53 PM
Bebida Roja
Bebida Roja - avatar