Sum of 100 digit numbers
I have two arrays each containing 100 digits.I need to add corresponding digits from units place meaning from the end of the array.If there is a carry it should be added in the next index.It should return another array containing the sum.
Here is my code and something seems to be wrong .Help me
void sumOf100DigitNumbers(int num1[100], int num2[100], int sum[101]) {
int i, j = 100, k;
for (i = 99; i >= 0; i--)
{
if (sum[j] == 1)
{
}
else
sum[j] = 0;
k = sum[j] + num1[i] + num2[i];
if (k >= 10)
{
sum[j] = k % 10;
sum[j - 1] = 1;
}
else
{
sum[j] = k;
}
j--;
}
}
Method to test it
[TestMethod, Timeout(1000)]
void Test_sumOf100DigitNumbers2()
{
int a[100] = {6, 8, 3, 7, 8, 1, 2, 4, 6, 7, 2, 0, 6, 6, 7, 0, 0, 9, 4, 8, 2, 9, 6, 3, 1, 7, 2, 3, 0, 4, 4, 5, 0, 9, 7, 0, 8, 9, 2, 6, 9, 2, 8, 8, 0, 2, 8, 2, 6, 5, 3, 0, 5, 2, 2, 5, 8, 8, 6, 6, 2, 3, 6, 0, 7, 0, 9, 9, 0, 4, 6, 4, 0, 4, 5, 1, 9, 5, 1, 5, 3, 6, 6, 3, 2, 4, 0, 7, 7, 8, 4, 6, 8, 7, 8, 9, 1, 6, 9, 2};
int b[100] = { 4, 1, 4, 1, 5, 0, 1, 8, 4, 5, 9, 7, 6, 2, 2, 0, 1, 7, 2, 5, 0, 3, 6, 9, 0, 8, 7, 3, 0, 2, 7, 8, 6, 5, 7, 3, 6, 8, 4, 2, 9, 2, 4, 8, 2, 1, 1, 0, 6, 6, 2, 7, 2, 8, 9, 7, 2, 4, 2, 2, 7, 6, 0, 7, 2, 3, 8, 4, 2, 5, 4, 7, 1, 8, 9, 9, 7, 0, 3, 2, 5, 1, 9, 7, 1, 0, 0, 0, 2, 1, 1, 5, 9, 0, 0, 1, 6, 6, 9, 7 };
int ans[101] = { 1, 0, 9, 7, 9, 3, 1, 4, 3, 1, 3, 1, 8, 2, 8, 9, 0, 2, 6, 7, 3, 3, 3, 3, 2, 2, 5, 9, 6, 0, 7, 2, 3, 7, 5, 4, 4, 5, 7, 6, 9, 8, 5, 3, 6, 2, 3, 9, 3, 3, 1, 5, 7, 8, 1, 2, 3, 1, 2, 8, 8, 9, 9, 6, 7, 9, 4, 8, 3, 3, 0, 1, 1, 2, 3, 5, 1, 6, 5, 4, 7, 8, 8, 6, 0, 3, 4, 0, 7, 9, 9, 6, 2, 7, 7, 9, 0, 8, 3, 8, 9 };
int c[101];
sumOf100DigitNumbers(a, b, c);
Assert::AreEqual(true, areEqualArrays(ans, c, 101), L"sumOf100DigitNumbers() failed", 1, 2);
};
but my output is as follows:
Output
c++ arrays while-loop
|
show 7 more comments
I have two arrays each containing 100 digits.I need to add corresponding digits from units place meaning from the end of the array.If there is a carry it should be added in the next index.It should return another array containing the sum.
Here is my code and something seems to be wrong .Help me
void sumOf100DigitNumbers(int num1[100], int num2[100], int sum[101]) {
int i, j = 100, k;
for (i = 99; i >= 0; i--)
{
if (sum[j] == 1)
{
}
else
sum[j] = 0;
k = sum[j] + num1[i] + num2[i];
if (k >= 10)
{
sum[j] = k % 10;
sum[j - 1] = 1;
}
else
{
sum[j] = k;
}
j--;
}
}
Method to test it
[TestMethod, Timeout(1000)]
void Test_sumOf100DigitNumbers2()
{
int a[100] = {6, 8, 3, 7, 8, 1, 2, 4, 6, 7, 2, 0, 6, 6, 7, 0, 0, 9, 4, 8, 2, 9, 6, 3, 1, 7, 2, 3, 0, 4, 4, 5, 0, 9, 7, 0, 8, 9, 2, 6, 9, 2, 8, 8, 0, 2, 8, 2, 6, 5, 3, 0, 5, 2, 2, 5, 8, 8, 6, 6, 2, 3, 6, 0, 7, 0, 9, 9, 0, 4, 6, 4, 0, 4, 5, 1, 9, 5, 1, 5, 3, 6, 6, 3, 2, 4, 0, 7, 7, 8, 4, 6, 8, 7, 8, 9, 1, 6, 9, 2};
int b[100] = { 4, 1, 4, 1, 5, 0, 1, 8, 4, 5, 9, 7, 6, 2, 2, 0, 1, 7, 2, 5, 0, 3, 6, 9, 0, 8, 7, 3, 0, 2, 7, 8, 6, 5, 7, 3, 6, 8, 4, 2, 9, 2, 4, 8, 2, 1, 1, 0, 6, 6, 2, 7, 2, 8, 9, 7, 2, 4, 2, 2, 7, 6, 0, 7, 2, 3, 8, 4, 2, 5, 4, 7, 1, 8, 9, 9, 7, 0, 3, 2, 5, 1, 9, 7, 1, 0, 0, 0, 2, 1, 1, 5, 9, 0, 0, 1, 6, 6, 9, 7 };
int ans[101] = { 1, 0, 9, 7, 9, 3, 1, 4, 3, 1, 3, 1, 8, 2, 8, 9, 0, 2, 6, 7, 3, 3, 3, 3, 2, 2, 5, 9, 6, 0, 7, 2, 3, 7, 5, 4, 4, 5, 7, 6, 9, 8, 5, 3, 6, 2, 3, 9, 3, 3, 1, 5, 7, 8, 1, 2, 3, 1, 2, 8, 8, 9, 9, 6, 7, 9, 4, 8, 3, 3, 0, 1, 1, 2, 3, 5, 1, 6, 5, 4, 7, 8, 8, 6, 0, 3, 4, 0, 7, 9, 9, 6, 2, 7, 7, 9, 0, 8, 3, 8, 9 };
int c[101];
sumOf100DigitNumbers(a, b, c);
Assert::AreEqual(true, areEqualArrays(ans, c, 101), L"sumOf100DigitNumbers() failed", 1, 2);
};
but my output is as follows:
Output
c++ arrays while-loop
3
I don't know what this is but it's not C. Wanna reformulate your tags?
– Havenard
Nov 12 at 15:53
5
"Something seems to be wrong." The first step when something seems to be wrong is to use a debugger. What did you discover when you used a debugger to step through the code?
– Raymond Chen
Nov 12 at 15:58
1
No it is definitively not C. Maybe it's C#.
– Havenard
Nov 12 at 15:59
2
Assert::AreEqual
is not valid C
– Broman
Nov 12 at 16:00
1
if (sum[j] == 1)
is invalid assum[j]
not yet assigned.
– chux
Nov 12 at 16:00
|
show 7 more comments
I have two arrays each containing 100 digits.I need to add corresponding digits from units place meaning from the end of the array.If there is a carry it should be added in the next index.It should return another array containing the sum.
Here is my code and something seems to be wrong .Help me
void sumOf100DigitNumbers(int num1[100], int num2[100], int sum[101]) {
int i, j = 100, k;
for (i = 99; i >= 0; i--)
{
if (sum[j] == 1)
{
}
else
sum[j] = 0;
k = sum[j] + num1[i] + num2[i];
if (k >= 10)
{
sum[j] = k % 10;
sum[j - 1] = 1;
}
else
{
sum[j] = k;
}
j--;
}
}
Method to test it
[TestMethod, Timeout(1000)]
void Test_sumOf100DigitNumbers2()
{
int a[100] = {6, 8, 3, 7, 8, 1, 2, 4, 6, 7, 2, 0, 6, 6, 7, 0, 0, 9, 4, 8, 2, 9, 6, 3, 1, 7, 2, 3, 0, 4, 4, 5, 0, 9, 7, 0, 8, 9, 2, 6, 9, 2, 8, 8, 0, 2, 8, 2, 6, 5, 3, 0, 5, 2, 2, 5, 8, 8, 6, 6, 2, 3, 6, 0, 7, 0, 9, 9, 0, 4, 6, 4, 0, 4, 5, 1, 9, 5, 1, 5, 3, 6, 6, 3, 2, 4, 0, 7, 7, 8, 4, 6, 8, 7, 8, 9, 1, 6, 9, 2};
int b[100] = { 4, 1, 4, 1, 5, 0, 1, 8, 4, 5, 9, 7, 6, 2, 2, 0, 1, 7, 2, 5, 0, 3, 6, 9, 0, 8, 7, 3, 0, 2, 7, 8, 6, 5, 7, 3, 6, 8, 4, 2, 9, 2, 4, 8, 2, 1, 1, 0, 6, 6, 2, 7, 2, 8, 9, 7, 2, 4, 2, 2, 7, 6, 0, 7, 2, 3, 8, 4, 2, 5, 4, 7, 1, 8, 9, 9, 7, 0, 3, 2, 5, 1, 9, 7, 1, 0, 0, 0, 2, 1, 1, 5, 9, 0, 0, 1, 6, 6, 9, 7 };
int ans[101] = { 1, 0, 9, 7, 9, 3, 1, 4, 3, 1, 3, 1, 8, 2, 8, 9, 0, 2, 6, 7, 3, 3, 3, 3, 2, 2, 5, 9, 6, 0, 7, 2, 3, 7, 5, 4, 4, 5, 7, 6, 9, 8, 5, 3, 6, 2, 3, 9, 3, 3, 1, 5, 7, 8, 1, 2, 3, 1, 2, 8, 8, 9, 9, 6, 7, 9, 4, 8, 3, 3, 0, 1, 1, 2, 3, 5, 1, 6, 5, 4, 7, 8, 8, 6, 0, 3, 4, 0, 7, 9, 9, 6, 2, 7, 7, 9, 0, 8, 3, 8, 9 };
int c[101];
sumOf100DigitNumbers(a, b, c);
Assert::AreEqual(true, areEqualArrays(ans, c, 101), L"sumOf100DigitNumbers() failed", 1, 2);
};
but my output is as follows:
Output
c++ arrays while-loop
I have two arrays each containing 100 digits.I need to add corresponding digits from units place meaning from the end of the array.If there is a carry it should be added in the next index.It should return another array containing the sum.
Here is my code and something seems to be wrong .Help me
void sumOf100DigitNumbers(int num1[100], int num2[100], int sum[101]) {
int i, j = 100, k;
for (i = 99; i >= 0; i--)
{
if (sum[j] == 1)
{
}
else
sum[j] = 0;
k = sum[j] + num1[i] + num2[i];
if (k >= 10)
{
sum[j] = k % 10;
sum[j - 1] = 1;
}
else
{
sum[j] = k;
}
j--;
}
}
Method to test it
[TestMethod, Timeout(1000)]
void Test_sumOf100DigitNumbers2()
{
int a[100] = {6, 8, 3, 7, 8, 1, 2, 4, 6, 7, 2, 0, 6, 6, 7, 0, 0, 9, 4, 8, 2, 9, 6, 3, 1, 7, 2, 3, 0, 4, 4, 5, 0, 9, 7, 0, 8, 9, 2, 6, 9, 2, 8, 8, 0, 2, 8, 2, 6, 5, 3, 0, 5, 2, 2, 5, 8, 8, 6, 6, 2, 3, 6, 0, 7, 0, 9, 9, 0, 4, 6, 4, 0, 4, 5, 1, 9, 5, 1, 5, 3, 6, 6, 3, 2, 4, 0, 7, 7, 8, 4, 6, 8, 7, 8, 9, 1, 6, 9, 2};
int b[100] = { 4, 1, 4, 1, 5, 0, 1, 8, 4, 5, 9, 7, 6, 2, 2, 0, 1, 7, 2, 5, 0, 3, 6, 9, 0, 8, 7, 3, 0, 2, 7, 8, 6, 5, 7, 3, 6, 8, 4, 2, 9, 2, 4, 8, 2, 1, 1, 0, 6, 6, 2, 7, 2, 8, 9, 7, 2, 4, 2, 2, 7, 6, 0, 7, 2, 3, 8, 4, 2, 5, 4, 7, 1, 8, 9, 9, 7, 0, 3, 2, 5, 1, 9, 7, 1, 0, 0, 0, 2, 1, 1, 5, 9, 0, 0, 1, 6, 6, 9, 7 };
int ans[101] = { 1, 0, 9, 7, 9, 3, 1, 4, 3, 1, 3, 1, 8, 2, 8, 9, 0, 2, 6, 7, 3, 3, 3, 3, 2, 2, 5, 9, 6, 0, 7, 2, 3, 7, 5, 4, 4, 5, 7, 6, 9, 8, 5, 3, 6, 2, 3, 9, 3, 3, 1, 5, 7, 8, 1, 2, 3, 1, 2, 8, 8, 9, 9, 6, 7, 9, 4, 8, 3, 3, 0, 1, 1, 2, 3, 5, 1, 6, 5, 4, 7, 8, 8, 6, 0, 3, 4, 0, 7, 9, 9, 6, 2, 7, 7, 9, 0, 8, 3, 8, 9 };
int c[101];
sumOf100DigitNumbers(a, b, c);
Assert::AreEqual(true, areEqualArrays(ans, c, 101), L"sumOf100DigitNumbers() failed", 1, 2);
};
but my output is as follows:
Output
c++ arrays while-loop
c++ arrays while-loop
edited Nov 12 at 16:12
SergeyA
41.1k53782
41.1k53782
asked Nov 12 at 15:50
Ananthhokage
32
32
3
I don't know what this is but it's not C. Wanna reformulate your tags?
– Havenard
Nov 12 at 15:53
5
"Something seems to be wrong." The first step when something seems to be wrong is to use a debugger. What did you discover when you used a debugger to step through the code?
– Raymond Chen
Nov 12 at 15:58
1
No it is definitively not C. Maybe it's C#.
– Havenard
Nov 12 at 15:59
2
Assert::AreEqual
is not valid C
– Broman
Nov 12 at 16:00
1
if (sum[j] == 1)
is invalid assum[j]
not yet assigned.
– chux
Nov 12 at 16:00
|
show 7 more comments
3
I don't know what this is but it's not C. Wanna reformulate your tags?
– Havenard
Nov 12 at 15:53
5
"Something seems to be wrong." The first step when something seems to be wrong is to use a debugger. What did you discover when you used a debugger to step through the code?
– Raymond Chen
Nov 12 at 15:58
1
No it is definitively not C. Maybe it's C#.
– Havenard
Nov 12 at 15:59
2
Assert::AreEqual
is not valid C
– Broman
Nov 12 at 16:00
1
if (sum[j] == 1)
is invalid assum[j]
not yet assigned.
– chux
Nov 12 at 16:00
3
3
I don't know what this is but it's not C. Wanna reformulate your tags?
– Havenard
Nov 12 at 15:53
I don't know what this is but it's not C. Wanna reformulate your tags?
– Havenard
Nov 12 at 15:53
5
5
"Something seems to be wrong." The first step when something seems to be wrong is to use a debugger. What did you discover when you used a debugger to step through the code?
– Raymond Chen
Nov 12 at 15:58
"Something seems to be wrong." The first step when something seems to be wrong is to use a debugger. What did you discover when you used a debugger to step through the code?
– Raymond Chen
Nov 12 at 15:58
1
1
No it is definitively not C. Maybe it's C#.
– Havenard
Nov 12 at 15:59
No it is definitively not C. Maybe it's C#.
– Havenard
Nov 12 at 15:59
2
2
Assert::AreEqual
is not valid C– Broman
Nov 12 at 16:00
Assert::AreEqual
is not valid C– Broman
Nov 12 at 16:00
1
1
if (sum[j] == 1)
is invalid as sum[j]
not yet assigned.– chux
Nov 12 at 16:00
if (sum[j] == 1)
is invalid as sum[j]
not yet assigned.– chux
Nov 12 at 16:00
|
show 7 more comments
1 Answer
1
active
oldest
votes
You never initialize c
. This means that its contents are indeterminate. You can't predict what values it will contain.
So when you do this:
if (sum[j] == 1)
If one of those indeterminate values happens to be 1 then you're performing a carry you don't intend on doing.
You can initialize it as follows:
int c[101] = { 0 };
Then you can remove this entirely:
if (sum[j] == 1)
{
}
else
sum[j] = 0;
thank you that solved my problem,although i didnt get what was i doing wrong previously .Thank you.
– Ananthhokage
Nov 12 at 16:52
@Ananthhokage The problem was thatc
was not initialized. That basically means that the elements of that array start with random values. If one of those random values happens to be 1, then you perform a carry that you shouldn't be.
– dbush
Nov 12 at 16:59
Thank you, i never knew that a garbage value can be 1 too.
– Ananthhokage
Nov 12 at 17:13
add a comment |
Your Answer
StackExchange.ifUsing("editor", function () {
StackExchange.using("externalEditor", function () {
StackExchange.using("snippets", function () {
StackExchange.snippets.init();
});
});
}, "code-snippets");
StackExchange.ready(function() {
var channelOptions = {
tags: "".split(" "),
id: "1"
};
initTagRenderer("".split(" "), "".split(" "), channelOptions);
StackExchange.using("externalEditor", function() {
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled) {
StackExchange.using("snippets", function() {
createEditor();
});
}
else {
createEditor();
}
});
function createEditor() {
StackExchange.prepareEditor({
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader: {
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
},
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
});
}
});
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53265652%2fsum-of-100-digit-numbers%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
1 Answer
1
active
oldest
votes
1 Answer
1
active
oldest
votes
active
oldest
votes
active
oldest
votes
You never initialize c
. This means that its contents are indeterminate. You can't predict what values it will contain.
So when you do this:
if (sum[j] == 1)
If one of those indeterminate values happens to be 1 then you're performing a carry you don't intend on doing.
You can initialize it as follows:
int c[101] = { 0 };
Then you can remove this entirely:
if (sum[j] == 1)
{
}
else
sum[j] = 0;
thank you that solved my problem,although i didnt get what was i doing wrong previously .Thank you.
– Ananthhokage
Nov 12 at 16:52
@Ananthhokage The problem was thatc
was not initialized. That basically means that the elements of that array start with random values. If one of those random values happens to be 1, then you perform a carry that you shouldn't be.
– dbush
Nov 12 at 16:59
Thank you, i never knew that a garbage value can be 1 too.
– Ananthhokage
Nov 12 at 17:13
add a comment |
You never initialize c
. This means that its contents are indeterminate. You can't predict what values it will contain.
So when you do this:
if (sum[j] == 1)
If one of those indeterminate values happens to be 1 then you're performing a carry you don't intend on doing.
You can initialize it as follows:
int c[101] = { 0 };
Then you can remove this entirely:
if (sum[j] == 1)
{
}
else
sum[j] = 0;
thank you that solved my problem,although i didnt get what was i doing wrong previously .Thank you.
– Ananthhokage
Nov 12 at 16:52
@Ananthhokage The problem was thatc
was not initialized. That basically means that the elements of that array start with random values. If one of those random values happens to be 1, then you perform a carry that you shouldn't be.
– dbush
Nov 12 at 16:59
Thank you, i never knew that a garbage value can be 1 too.
– Ananthhokage
Nov 12 at 17:13
add a comment |
You never initialize c
. This means that its contents are indeterminate. You can't predict what values it will contain.
So when you do this:
if (sum[j] == 1)
If one of those indeterminate values happens to be 1 then you're performing a carry you don't intend on doing.
You can initialize it as follows:
int c[101] = { 0 };
Then you can remove this entirely:
if (sum[j] == 1)
{
}
else
sum[j] = 0;
You never initialize c
. This means that its contents are indeterminate. You can't predict what values it will contain.
So when you do this:
if (sum[j] == 1)
If one of those indeterminate values happens to be 1 then you're performing a carry you don't intend on doing.
You can initialize it as follows:
int c[101] = { 0 };
Then you can remove this entirely:
if (sum[j] == 1)
{
}
else
sum[j] = 0;
answered Nov 12 at 16:00
dbush
91.9k12100131
91.9k12100131
thank you that solved my problem,although i didnt get what was i doing wrong previously .Thank you.
– Ananthhokage
Nov 12 at 16:52
@Ananthhokage The problem was thatc
was not initialized. That basically means that the elements of that array start with random values. If one of those random values happens to be 1, then you perform a carry that you shouldn't be.
– dbush
Nov 12 at 16:59
Thank you, i never knew that a garbage value can be 1 too.
– Ananthhokage
Nov 12 at 17:13
add a comment |
thank you that solved my problem,although i didnt get what was i doing wrong previously .Thank you.
– Ananthhokage
Nov 12 at 16:52
@Ananthhokage The problem was thatc
was not initialized. That basically means that the elements of that array start with random values. If one of those random values happens to be 1, then you perform a carry that you shouldn't be.
– dbush
Nov 12 at 16:59
Thank you, i never knew that a garbage value can be 1 too.
– Ananthhokage
Nov 12 at 17:13
thank you that solved my problem,although i didnt get what was i doing wrong previously .Thank you.
– Ananthhokage
Nov 12 at 16:52
thank you that solved my problem,although i didnt get what was i doing wrong previously .Thank you.
– Ananthhokage
Nov 12 at 16:52
@Ananthhokage The problem was that
c
was not initialized. That basically means that the elements of that array start with random values. If one of those random values happens to be 1, then you perform a carry that you shouldn't be.– dbush
Nov 12 at 16:59
@Ananthhokage The problem was that
c
was not initialized. That basically means that the elements of that array start with random values. If one of those random values happens to be 1, then you perform a carry that you shouldn't be.– dbush
Nov 12 at 16:59
Thank you, i never knew that a garbage value can be 1 too.
– Ananthhokage
Nov 12 at 17:13
Thank you, i never knew that a garbage value can be 1 too.
– Ananthhokage
Nov 12 at 17:13
add a comment |
Thanks for contributing an answer to Stack Overflow!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Some of your past answers have not been well-received, and you're in danger of being blocked from answering.
Please pay close attention to the following guidance:
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53265652%2fsum-of-100-digit-numbers%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
3
I don't know what this is but it's not C. Wanna reformulate your tags?
– Havenard
Nov 12 at 15:53
5
"Something seems to be wrong." The first step when something seems to be wrong is to use a debugger. What did you discover when you used a debugger to step through the code?
– Raymond Chen
Nov 12 at 15:58
1
No it is definitively not C. Maybe it's C#.
– Havenard
Nov 12 at 15:59
2
Assert::AreEqual
is not valid C– Broman
Nov 12 at 16:00
1
if (sum[j] == 1)
is invalid assum[j]
not yet assigned.– chux
Nov 12 at 16:00