Can anyone help me by explaining how to write test case for simple c programs
The build-in c_program question type assumes that the student's program will read standard input and generate some standard output. So each test case simply defines the standard input plus the expected standard output. Additional data files can be supplied via the Support files section of the question editing form - these are all loaded into the working directory before the program is run.
Thank You Richard Lobb !
Apologies for not properly putting up my query in earlier message. I was actually stuck at the point as what is to be entered in the first test case 1 box, others standard input, expected are pretty much straight forward. But I left it blank and it worked absolutely fine.
I have another query, will start a separate discussion topic for the same.
Apologies for not properly putting up my query in earlier message. I was actually stuck at the point as what is to be entered in the first test case 1 box, others standard input, expected are pretty much straight forward. But I left it blank and it worked absolutely fine.
I have another query, will start a separate discussion topic for the same.
Here are a example for this answer: Copy and paste the my answer into the answer-textfield and add some text into the question-textfield. Also check the `checkbox` under the answer - this will generate automatically the required answer ...
#include <stdio.h>
int main(){
int userInput = 0;
int output = 0;
printf("########### INPUT ###########\n");
printf("Please insert a number: \n");
scanf("%d", &userInput);
int result = userInput % 5;
switch(result){
case 0:
output = userInput * 2;
break;
case 2:
output = userInput / 2;
break;
case 3:
output = userInput + 3;
break;
default:
output = userInput - 4;
break;
}
printf("########### OUTPUT ###########\n");
printf("The new value is: %d\n", output);
return 0;
}
Thanks sc kaindorf