Note that there are some explanatory texts on larger screens.

plurals
  1. POHow to test my program against an input test case file
    text
    copied!<p>I was participating in some coding contests and luckily my code also ran. However my solution was not expected because i was wrong with the pattern of taking input. </p> <hr> <p>The question involved taking in an integer as an input and performing some operation and returning a different or same integer. I do not have any problem with the program, I just don't know how to code so as to take inputs like this</p> <hr> <pre><code>Input The input will contain several test cases (not more than 10). Each test case is a single line with a number n, 0 &lt;= n &lt;= 1 000 000 000. It is the number given as input. Output For each test case output a single line, containing the integer returned. </code></pre> <hr> <pre><code>Example Input: 12 2 Output: 13 2 </code></pre> <hr> <p>My code is </p> <hr> <pre><code>#include &lt;stdio.h&gt; int functionReturningInteger(int n) { // implementation ........ return num; } int main(void) { int number; //printf("Enter the number: "); scanf("%d",&amp;number); printf(functionReturningInteger(number)); return 0; </code></pre> <p>}</p> <hr> <p>How am i supposed to know how many inputs they will give ( although they do provide a maximum limit). And if i use an array to store these inputs whose size is equal to the maximum limit, how do i check the size of an integer array in c ?</p> <hr> <p>I will appreciate anybody helping out with a small piece of code. Also if am able to test it against an input test file and generate an "output.txt" (output file). I already have the desired output file "des.txt". Then how can i match whether both the files are same or not ?</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload