printTable
Error Debugging
printTable
Problem Statement
You are required to fix all logical errors in the given Code. You can Compile & Run to check the compilation/execution status of the program. You can use printf to debug your code. The submitted code should be logically/syntactically correct and pass all testcases. Do not write the main() function as it is not required.Code Approach
For this question, you will need to correct the given implementation. We do not expect you to modify the approach or incorporate any additional library methods
The function printTable(int num) is supposed to print the first ten multiples of the multiplication table of the input number num.
The function compiles fine but fails to return the desired results for some cases.
Your task is to fix the program so that it passes all the test cases.
Test Cases
Test Case 1
Input
6
Expected Return Value
6 12 18 24 30 36 42 48 54 60Test case 2
Input
0
Expected Return Values
0 0 0 0 0 0 0 0 0 0
Error Debugging
void printTable(int num){ int value=0; for(int i=0;i<10;i++){ value=num*i; printf("%d ",value); } }
Solution
void printTable(int num){ int value=0; for(int i=1;i<=10;i++){ value=num*i; printf("%d ",value); } }
//Published by PKJCODERS (Note: Incase If the code doesn't Pass the output kindly comment us with your feedback to help us improvise.)
Comments