0
Explain why gives output %%d
#include<iostream> using namespace std; int main(){ int a=10; printf("%%%%%%d"+1); return 0; }
2 ответов
+ 2
Abhishek Bairwa
because first two %% output as %,
then next two %% output as %, third one similary, and finally d...
% is the character used to escape variable placeholder, so to output % you need to escape it ;)
+ 1
Are you sure it shows %%d? Running in the code playground shows me %%{random large number}, which is an output I will expect, so I will instead explain the output I get.
"%%%%%%d"+1 becomes "%%%%%d". The number of % becomes 5 because the +1.
%% outputs % in literal
So %%%% outputs %%.
And the final %d, because you didn't give any parameter for it. It outputs random number which I think is a garbage number, but I can't ensure about that.