Table 6, what am I missing? LANGUAGE C

Asked

Viewed 51 times

-1

Not giving the results, always 0

#include <stdio.h>
#include <stdlib.h>
#include <locale.h>

main ()
{
	setlocale(LC_ALL, "Portuguese");
	int i; 
	for (i = 1; i <= 10; i++)
	{
		printf("6 X %.0f = %.0f\n",i, 6*i);
	}
	return 0;
	system("pause");

}

  • what are you seeing go wrong ? what you wanted to happen and isn’t happening ?

  • n, is giving the result in all 0 :/

  • Wesley, could you comment on the purpose of this %.0f of your code and how you got into it?

  • %.0f or use to show where there will be a variable, then I put the variables and each variable goes to a defined place. if it has two variables, the first %.0f and the second %.0f

  • So, my teacher who told you to use this kkkk

  • 1

    I doubt for a moment that he said that, probably his interpretation was superficial - although nowadays he does not doubt anything about teachers. - Anyway, you should use language documentation as a basis, not "find" anything.

  • 1

    I doubt less than Bacco, but I also doubt :) At least not in this context I think he did not say exactly this.

  • Could you explain to me in what context use the "%. 0f"?

  • 1

    The good thing would be to read the documentation. See this answer here, it may help you understand about the printf family placeholders: https://answall.com/a/10880/70

  • This teacher is complicated... It does not explain almost anything, we have to stay looking for solutions

  • Thank you so much :) Good Sunday

  • 2

    Now I realize that the teacher is great, he sends students who will work in a profession that is finding solutions all the time to do what? Finding solutions! I wish all teachers were like that.

Show 7 more comments

1 answer

2


It’s actually quite simple, your mistake is in the printf within the for, in it you’re wearing %.0f but this formatting is for float and your value is int, then use the %d, see rotating on IDEONE.

  • Ahhh, thank you very much, I didn’t know that this format was for float

  • A decent compiler would have issued a Warning regarding this

  • @epx, it’s true, possibly he must be using some outdated version.

Browser other questions tagged

You are not signed in. Login or sign up in order to post.