Home > Blockchain >  C Program Printing 0 When Numbers Too Large
C Program Printing 0 When Numbers Too Large

Time:03-14

I'm trying to write a program that prints the factorial of a number:

#include <iostream>
using namespace std;

int main() {
    int ans,fact=1, number;
    cin>>number;

    for (int i=1; i<=number; i  ) {
        fact = fact*i;
    }
    ans = fact           
  •  Tags:  
  • c
  • Related