#1
  1. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Sep 2017
    Posts
    1
    Rep Power
    0

    How to pass private test Cases ?


    I have written a program to find the factorial of a non-negative numberI it will be passed as the first command line parameter )
    .I have to write the output to stdout formatted as an integer Without any other additional text assuming that You may assume that the input integer will be such that the output will not exceed the largest possible integer that can be stored in an int type variable
    .My code is

    Code:
    # include<stdio.h>
     # include<stdlib.h>
     int main( int argc , char *argv[])
     { int fact,i,n;
     fact=1;
     n=atoi(argv[1]);
     if(n==0)
      fact=0;
     else
     { for(i=1;i<=n;i++)
       { fact=fact*i;
        }
     }
    printf("%d",fact);
    }
    I am running this code on a portal . There are 4 test cases 1 public test case and 3 private test cases . With this code I have successfully passed all the test cases except for 1 private test case . I want to know what are private test cases and how do I find out that what have I missed in my program ?
  2. #2
  3. Lazy Moderator
    Devshed Supreme Being (6500+ posts)

    Join Date
    Mar 2007
    Location
    Washington, USA
    Posts
    16,435
    Rep Power
    9645
    You can't really find out what the test case is directly. You'll have to find flaws in your program.

    What those flaws are might not be easy to find. I do know that typically 0! = 1. Otherwise they tend to be error checks; do you have instructions about invalid inputs?
  4. #3
  5. Contributing User
    Devshed God 1st Plane (5500 - 5999 posts)

    Join Date
    Aug 2011
    Posts
    5,888
    Rep Power
    509
    Gee I think you nailed it:
    if(n==0)

    fact=0;

    then again, the problem could involve the lack of input validation. Install a little more code to email the input to yourself.
    [code]Code tags[/code] are essential for python code and Makefiles!

IMN logo majestic logo threadwatch logo seochat tools logo