output:Code:#include<stdio.h> void main() { printf("%%%%\n"); }
%%
Why the output is '%%'??
Why not '%%%%'?
If I replace '%' with '$', then output is '$$$$'. Why?
output:Code:#include<stdio.h> void main() { printf("%%%%\n"); }
%%
Why the output is '%%'??
Why not '%%%%'?
If I replace '%' with '$', then output is '$$$$'. Why?
I am using Turbo C 4.5 on Windows 7 platform
'%' is a format specifier. It has special meaning. Just like '\' is expecting more characters afterwards but if you want '\' output then you have to use '\\'.
My condolences...
(You really should think about a better compiler, something like ... Pelles C)
Yes. I made the changes and got the answer. Thank you.
Thank you Tater. I will try to get that one.
you should also know that the return type of main is int not void.and you can't get away with void main() in up-to-date compilers like pelles c. read this
Cprogramming.com FAQ > main() / void main() / int main() / int main(void) / int main(int argc, char *argv[])
the printf() function uses the % symbol to identify the conversion specifications, there is a slight problem if you want to print the % sign itself. If you simply use a lone % sign, the compiler thinks you have bungled a conversion specification. The way out is simple—just use two % symbols, as shown here:
pc = 2*6; printf("Only %d%% of Sally's gribbles were edible.\n", pc);
The following output would result:
Only 12% of Sally's gribbles were edible.