EmbLogic's Blog

why printf giving value without using variable name

int ten = 10;
int two = 2,z=3;
printf(“Doing it right: “);
printf(“%d minus %d is %d \n”,ten,2,ten-two);
printf(“Doing it wrong: “);
printf(“%d minus %d is %d\n”,ten); // In this function i have not used the variable name “ten” then why it is not giving the error on compilation.

if “,” and name of variable are not declared then it also give output instead of error.

OUTPUT

Doing it right: 10 minus 2 is 8
Doing it wrong: 10 minus 2 is 8

if i use

printf(“%d minus %d is %d\n”,z);

then OUTPUT

Doing it wrong: 3 minus 2 is 8

Leave a Reply

Your email address will not be published. Required fields are marked *

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>