printf affects following printf/s

Joined
Oct 17, 2010
Messages
1
Reaction score
0
Hi,
I spotted that when I use a typecasting in printf the next printf behaves according to that typecasting. I wonder why. Thanks. Here is a 2 example.
If you comment out second printf the third printf's output changes accordingly.

Code:
#include <stdio.h>
#include <stdlib.h>
#define RECT_AREA(x, y) (x)*(y)

int main(int argc, char *argv[]){
    printf("%f\n", RECT_AREA(10, 5));
    printf("%f\n", RECT_AREA(10.0, 5));
    printf("%f\n", RECT_AREA(10, 5));
    return EXIT_SUCCESS;
}

Code:
#include <stdio.h>
#include <stdlib.h>

int main(int argc, char *argv[]){
    printf("%f\n", 10*5);
    printf("%f\n", 10.0*5);
    printf("%f\n", 10*5);
    return EXIT_SUCCESS;
}
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,769
Messages
2,569,580
Members
45,055
Latest member
SlimSparkKetoACVReview

Latest Threads

Top