Skip to main content
Post Undeleted by Bryan
Fixed code formatting
Source Link
Bryan
  • 21
  • 2

C

#include <stdio<std\
io.h> 
#include \
<stdlib.h>

int main(int argc
 , char** argv)
{
    // iteratively 
 compute factorial here

 // compute factorial here
long int n = \
0, i \
= 0, r = \
1 /*  
product starts at one *one*/;

    if (argc  
> 1)
    {
        n =  
strtol(argv[1]argv[\
1], NULL, 10);
       ; if (n  
< 0)
        {
       printf("Arg must\
    printf("arg must  be >= 0\n");
            exit(-1);
        1);}
    }

    i =  
n;
    while (i)
    {
        r  
= r * i;
        i 
--;
    }

  /* print
the result*/ printf("%ld factorial
"%d isfactorial\
equals %ld\n"%d\
\n", n 
, r);
    /*done*/ done
}

Pronounciation:

pound include standard
I/O dot h pound include
standard lib dot h

int main int arg c
comma char star star arg v
open brace comment

iteratively
compute factorial here
long int n equals

zero comma i
equals zero comma r
equals one comment

product starts at one
semicolon if arg c
is greater than one

open brace n is
str-to-l of arg v sub
one comma NULL comma ten

semicolon if
n less than zero openbegin
brace printfprintf arg must

be greater than or
equal to zero backslash
n semicolon

exit negative
one semicolon end brace
end brace i equals

n semicolon
while i open brace r
equals r times i

semicolon i
decrement semicolon
close brace comment print

the result printf
percent d factorial
equals percent d

whack n comma n
comma r semicolon
comment done end brace

C

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

int main(int argc, char** argv)
{
    // iteratively compute factorial here

    long int n = 0, i = 0, r = 1 /* product starts at one */;

    if (argc > 1)
    {
        n = strtol(argv[1], NULL, 10);
        if (n < 0)
        {
            printf("arg must be >= 0\n");
            exit(-1);
        }
    }

    i = n;
    while (i)
    {
        r = r * i;
        i--;
    }

     printf("%ld factorial is %ld\n", n, r);
    // done
}

Pronounciation:

pound include standard
I/O dot h pound include
standard lib dot h

int main int arg c
comma char star star arg v
open brace comment

iteratively
compute factorial here
long int n equals

zero comma i
equals zero comma r
equals one comment

product starts at one
semicolon if arg c
is greater than one

open brace n is
str-to-l of arg v sub
one comma NULL comma ten

semicolon if
n less than zero open
brace printf arg must

be greater than or
equal to zero backslash
n semicolon

exit negative
one semicolon end brace
end brace i equals

n semicolon
while i open brace r
equals r times i

semicolon i
decrement semicolon
close brace comment print

the result printf
percent d factorial
equals percent d

whack n comma n
comma r semicolon
comment done end brace

C

#include <std\
io.h> 
#include \
<stdlib.h>

int main(int argc
 , char** argv)
{   // iteratively 
    // compute factorial here
long int n = \
0, i \
= 0, r = \
1 /* 
product starts at one*/;

if (argc  
> 1) { n =  
strtol(argv[\
1], NULL, 10)
; if (n  
< 0) {
       printf("Arg must\
       be >= 0\n");
       exit(-
    1);}
} i =  
n;
while (i) { r  
= r * i;
    i 
--;
} /* print
the result*/ printf(
"%d factorial\
equals %d\
\n", n 
, r);
/*done*/}

Pronounciation:

pound include standard
I/O dot h pound include
standard lib dot h

int main int arg c
comma char star star arg v
open brace comment

iteratively
compute factorial here
long int n equals

zero comma i
equals zero comma r
equals one comment

product starts at one
semicolon if arg c
is greater than one

open brace n is
str-to-l of arg v sub
one comma NULL comma ten

semicolon if
n less than zero begin
printf arg must

be greater than or
equal to zero backslash
n semicolon

exit negative
one semicolon end brace
end brace i equals

n semicolon
while i open brace r
equals r times i

semicolon i
decrement semicolon
close brace comment print

the result printf
percent d factorial
equals percent d

whack n comma n
comma r semicolon
comment done end brace

Post Deleted by Bryan
deleted 15 characters in body
Source Link
Bryan
  • 21
  • 2

C

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

int main(int argc, char** argv)
{
    // iteratively compute factorial here

    long int n = 0, i = 0, r = 1 /* product starts at one */;

    if (argc > 1)
    {
        n = strtol(argv[1], NULL, 10);
        if (n < 0)
        {
            printf("arg must be >= 0\n");
            exit(-1);
        }
    }

    i = n;
    while (i)
    {
        resultr = resultr * i;
        i--;
    }

    printf("%ld factorial is %ld\n", n, resultr);
    // done
}

Pronounciation:

pound include standard
I/O dot h pound include
standard lib dot h

int main int arg c
comma char star star arg v
open brace comment

iteratively
compute factorial here
long int n equals

zero comma i
equals zero comma r
equals one comment

product starts at one
semicolon if arg c
is greater than one

open brace n is
str-to-l of arg v sub
one comma NULL comma ten

semicolon if
n less than zero open
brace printf arg must

be greater than or
equal to zero backslash
n semicolon

exit negative
one semicolon end brace
end brace i equals

n semicolon
while i open brace r
equals r times i

semicolon i
decrement semicolon
close brace comment print

the result printf
percent d factorial
equals percent d

whack n comma n
comma r semicolon
comment done end brace

C

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

int main(int argc, char** argv)
{
    // iteratively compute factorial here

    long int n = 0, i = 0, r = 1 /* product starts at one */;

    if (argc > 1)
    {
        n = strtol(argv[1], NULL, 10);
        if (n < 0)
        {
            printf("arg must be >= 0\n");
            exit(-1);
        }
    }

    i = n;
    while (i)
    {
        result = result * i;
        i--;
    }

    printf("%ld factorial is %ld\n", n, result);
    // done
}

Pronounciation:

pound include standard
I/O dot h pound include
standard lib dot h

int main int arg c
comma char star star arg v
open brace comment

iteratively
compute factorial here
long int n equals

zero comma i
equals zero comma r
equals one comment

product starts at one
semicolon if arg c
is greater than one

open brace n is
str-to-l of arg v sub
one comma NULL comma ten

semicolon if
n less than zero open
brace printf arg must

be greater than or
equal to zero backslash
n semicolon

exit negative
one semicolon end brace
end brace i equals

n semicolon
while i open brace r
equals r times i

semicolon i
decrement semicolon
close brace comment print

the result printf
percent d factorial
equals percent d

whack n comma n
comma r semicolon
comment done end brace

C

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

int main(int argc, char** argv)
{
    // iteratively compute factorial here

    long int n = 0, i = 0, r = 1 /* product starts at one */;

    if (argc > 1)
    {
        n = strtol(argv[1], NULL, 10);
        if (n < 0)
        {
            printf("arg must be >= 0\n");
            exit(-1);
        }
    }

    i = n;
    while (i)
    {
        r = r * i;
        i--;
    }

    printf("%ld factorial is %ld\n", n, r);
    // done
}

Pronounciation:

pound include standard
I/O dot h pound include
standard lib dot h

int main int arg c
comma char star star arg v
open brace comment

iteratively
compute factorial here
long int n equals

zero comma i
equals zero comma r
equals one comment

product starts at one
semicolon if arg c
is greater than one

open brace n is
str-to-l of arg v sub
one comma NULL comma ten

semicolon if
n less than zero open
brace printf arg must

be greater than or
equal to zero backslash
n semicolon

exit negative
one semicolon end brace
end brace i equals

n semicolon
while i open brace r
equals r times i

semicolon i
decrement semicolon
close brace comment print

the result printf
percent d factorial
equals percent d

whack n comma n
comma r semicolon
comment done end brace

Source Link
Bryan
  • 21
  • 2

C

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

int main(int argc, char** argv)
{
    // iteratively compute factorial here

    long int n = 0, i = 0, r = 1 /* product starts at one */;

    if (argc > 1)
    {
        n = strtol(argv[1], NULL, 10);
        if (n < 0)
        {
            printf("arg must be >= 0\n");
            exit(-1);
        }
    }

    i = n;
    while (i)
    {
        result = result * i;
        i--;
    }

    printf("%ld factorial is %ld\n", n, result);
    // done
}

Pronounciation:

pound include standard
I/O dot h pound include
standard lib dot h

int main int arg c
comma char star star arg v
open brace comment

iteratively
compute factorial here
long int n equals

zero comma i
equals zero comma r
equals one comment

product starts at one
semicolon if arg c
is greater than one

open brace n is
str-to-l of arg v sub
one comma NULL comma ten

semicolon if
n less than zero open
brace printf arg must

be greater than or
equal to zero backslash
n semicolon

exit negative
one semicolon end brace
end brace i equals

n semicolon
while i open brace r
equals r times i

semicolon i
decrement semicolon
close brace comment print

the result printf
percent d factorial
equals percent d

whack n comma n
comma r semicolon
comment done end brace