![]() |
Problem during runtime: Cofactor
Hello everyone, I am Arkaprava, a college student.....I am having huge problem regarding running the following program....please help me out. It has no compilation error but during runtime, it is giving rise to strange values.....please debug it....
Thanks in advance.... Code:
#include<stdio.h>@rk@ |
Re: Problem during runtime: Cofactor
What input do you give it? What is the strange output? What output did you expect?
|
Re: Problem during runtime: Cofactor
No output....it is showing error in processing data whenever I enter row=1, column=1.
I expect to print the entire cofactor matrix of that corresponding element. |
Re: Problem during runtime: Cofactor
First of all please switch to a sensible way of getting data from the user:
Code:
printf("enter a number: ");No output at all? Are you sure about that? After you've entered 1 for m and n I would expect to see at least "Enter the element a[0][0]=". If you're not seeing that then "scanf("%d", &n);" must be crashing. By output I mean stuff displayed on the screen by the program, not necessarily final results. There must be some output if it's showing an error. So what error is it showing? (The program doesn't display "error in processing data" at any point, unless you've added that since uploading the code.) |
Re: Problem during runtime: Cofactor
Not error as such....it's showing an invalid output for the matrix {{1,2,3},{4,5,6},{7,8,9}}.
For row index 1 and column index 1 it is givin the cofactor {{-1,8653},{9119,22053}}...... Thanks for the advise regarding scanf....I did not know......could u teach me a bit more elaborately?? please???? |
Re: Problem during runtime: Cofactor
What output did you expect? Sorry, I know nothing about cofactors so I don't know.
Have you tried adding debug statements to the code to determine where the silly values are coming from? For example you can display the values in the first for loop with something like: Code:
printf("Assigning a[i=%d][j=%d]=%d to b[i][j]\n", i, j, a[i][j]); |
Re: Problem during runtime: Cofactor
Yes I can....help me in debugging the program.....
for cofactor, please see here..... [link]http://en.wikipedia.org/wiki/Cofactor_(linear_algebra)[/link] |
Re: Problem during runtime: Cofactor
Yes I have tried adding debugging code....but it did not help much....
|
Re: Problem during runtime: Cofactor
> .help me in debugging the program
Yes, to that end I've asked some questions which so far you haven't answered. - What output did you expect? (Pointing me to a tutorial on cofactors doesn't answer this) If adding debugging code didn't help then try adding more. Those dodgy values must be coming from SOMEWHERE. - What output did the code I suggested display? - Did you try adding equivalent code to the other loops? What exactly are you expecting "return b[size-1][size-1];" to return to the caller ( using test matrix {{1,2,3},{4,5,6},{7,8,9}} ) ? |
Re: Problem during runtime: Cofactor
Dear sir....I beg thousand perdons....I expected my output to be {{1,3},{7,9}}....
And I ave tried ALL the codes you have referred....and it is still undone.....some of your codes are not working in my compiler....probably because it is very old one... I have tried equivalent codes in each and every loop.... I will still try to work it out....I have spend the whole yesterday behind this one.... I will use more debugging codes and will give you the ultimate feedback.....thanks for all your advises.... |
| All times are GMT +5.5. The time now is 18:58. |