top button
Flag Notify
    Connect to us
      Site Registration

Site Registration

Print factorial of a number without using semicolon using C?

+3 votes
451 views
Print factorial of a number without using semicolon using C?
posted Jan 25, 2016 by anonymous

Share this question
Facebook Share Button Twitter Share Button LinkedIn Share Button

1 Answer

+2 votes

The catch is in all the places use if or while/for to make a statement where ever u need semicolon. Something like as follows -

#include <stdio.h>

void main(int n, int f)
{
    if (scanf("%d", &n))
    {
        if (f = 1)
        {
            while (n != 1)
            {
                if (f = n * f)
                    if (n--) {}
            }                 
            if(printf("Factorial is %d\n", f)) {}
        }
    }
}
answer Jan 26, 2016 by Salil Agrawal
Similar Questions
+3 votes

Decimal to Factorial
23(D) = 3210(F)

23 / 3! = 3 (5)
5 / 2! = 2 (1)
1 / 1! = 1 (0)
0 / 0! = 0 (0)

Factorial to Decimal
3210(F)=23(D),
3*3!+2*2!+1*1!+0*0! = 23(D)

–1 vote

Given an ODD number, print diamond pattern of stars recursively.

Example
Input: n = 5,

Output:

  *
 ***
*****
 ***
  *
...