Quantcast
Channel: CodeChef Discuss - latest questions
Viewing all articles
Browse latest Browse all 39796

What is wrong with my code for calculating factorials?

$
0
0

Here's the code :

#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.


Viewing all articles
Browse latest Browse all 39796

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>