#include <stdio.h>
int main (void)
{
int x, y, z;
z = 1;
scanf ("%i", &x);
for (x; x > 0; --x)
{
scanf ("%i", &y);
for (y = 1; y; ++y)
{
z = z * y;
}
printf ("%i\n", &z);
}
return 0;
}
Please don’t give me the solution. I am new to programming and I haven’t learn’t anything except loops and if else statements.
@gautam94: Correction in the above code whose ideone link you have posted:
Well, you’re almost there. You don’t have to use “&” operator while printing. The “weird” output is basically printing the address reference of that particular variable.
In short, use:
<pre> printf ("%i\n", z);
If you use:
<pre> printf ("%i\n", &z);
then it will print the address of z. and yeah your code produces correct output after this midification
@betlista i just realized you commented after i deleted mine. Sorry about that.
Well, i saw the link. Sorry sir, i in no way meant that question is bad. But i thought-that while scrolling the discuss homepage say someone feels like answering some question. If it is closed he knows that the question is answered or invalid, & for a person who himself is looking for answers then he will also know which question to see(as there are multiple searches for a single keyword).
So, basically i just felt that it would keep the whole and forum process cleaner Not to insult anyone in anyway:)
@sunny_patel: Thanks for taking care for forum. Questions with accepted answer are marker green in list (similarly as questions without answer are red). Probably if you want, you can instead of closing questions, find questions that are answered but author didn’t accept any answer and choose the best one and accept it (if you have privileges already). But, I’m not doing this, because I think that users have to learn how to use this forum