in Education by
// merge.cpp // merges two containers into a third #include #include //for merge() using namespace std; int src1[] = { 2, 3, 4, 6, 8 }; int src2[] = { 1, 3, 5 }; int dest[8]; int main() { //merge src1 and src2 into dest merge(src1, src1+5, src2, src2+3, dest); for(int j=0; j<8; j++) //display dest cout << dest[j] << ' '; cout << endl; return 0; } this is the code that I typed and what I expected was a sorted merged array, but the output came out to be : 1210537622105376321053763210537642105376521053766210537682105376 I varied the data, rechecked the syntax but every thing is fine , I think JavaScript questions and answers, JavaScript questions pdf, JavaScript question bank, JavaScript questions and answers pdf, mcq on JavaScript pdf, JavaScript questions and solutions, JavaScript mcq Test , Interview JavaScript questions, JavaScript Questions for Interview, JavaScript MCQ (Multiple Choice Questions)

1 Answer

0 votes
by
In c++ this is a character ' ' (single quotation marks) and this is a string " " (double quotation marks). Avoid to use single quotation marks for more than one character as it is implementation defined. Fix cout << dest[j] << ' '; to cout << dest[j] << ' '; // remove one whitespace or cout << dest[j] << " "; // change to string A multi-character character constant is interpreted as integer. In your case ' ' is 2105376. With g++ and clang++ ' ' is translated to 8224 = 256 * ' ' + ' '. In your example either you forgot one whitespace or your compiler translates with a different method: 2105376 = 256 * 256 * ' ' + 256 * ' '+ ' ' Enable and read compiler warnings. This was the first thing the compiler told me. :13:24: warning: multi-character character constant [-Wmultichar]

Related questions

0 votes
    I have a function value(x) which is overloaded for many types such that: double value(double x) { return x; } double ... [-Wreturn-local-addr] in the following code: Matrix33 m; m...
asked Apr 24, 2022 in Education by JackTerrance
0 votes
    #include using namespace std; template class test { T y; public: test(T k) : y(k) {} friend int a(T& x); }; template int a(T& x) { cout...
asked Feb 18, 2022 in Education by JackTerrance
0 votes
    #include using namespace std; template class test { T y; public: test(T k) : y(k) {} friend int a(T& x); }; template int a(T& x) { cout...
asked Feb 18, 2022 in Education by JackTerrance
0 votes
    #include using namespace std; template class test { T y; public: test(T k) : y(k) {} friend int a(T& x); }; template int a(T& x) { cout...
asked Feb 16, 2022 in Education by JackTerrance
0 votes
    This question's answers are a community effort. Edit existing answers to improve this post. It is not ... Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked Mar 20, 2022 in Education by JackTerrance
0 votes
    ________ function generates n normal random numbers based on the mean and standard deviation arguments passed to ... R Programming Select the correct answer from above options...
asked Feb 15, 2022 in Education by JackTerrance
0 votes
    I've been trying for some time now to get a screen-space pixel (provided by a deferred HLSL ... JavaScript Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked Jun 8, 2022 in Education by JackTerrance
0 votes
    #include struct A { bool f( int a ) { std::cout...
asked Feb 21, 2022 in Education by JackTerrance
0 votes
    Sorry for what may sound simple, but I am trying to draw just a simple box in Visual Studio 2017 using the unicode ... code below #include using namespace std; int main() { cout...
asked Apr 21, 2022 in Education by JackTerrance
0 votes
    Two vectors M and N are defined as M...
asked Feb 12, 2022 in Education by JackTerrance
0 votes
    _____________ function is preferred over sapply as vapply allows the programmer to specific the output type. (a) ... of R Programming Select the correct answer from above options...
asked Feb 15, 2022 in Education by JackTerrance
0 votes
    If a programmer wants the output to be a list then ___________ function is used. (a) Lapply (b) Sapply ... Debugging of R Programming Select the correct answer from above options...
asked Feb 15, 2022 in Education by JackTerrance
0 votes
    If the programmers want the output to be a data frame or a vector, then ________ function is used. (a) ... Debugging of R Programming Select the correct answer from above options...
asked Feb 13, 2022 in Education by JackTerrance
0 votes
    To release a package to _____ you must pick a standard license. (a) R (b) CRAN (c) CRON (d) ... Linear Regression of R Programming Select the correct answer from above options...
asked Feb 10, 2022 in Education by JackTerrance
0 votes
    What will be the output of log (-5.8) when executed on R console? (a) NAN (b) NA (c) Error ... Functions and Debugging of R Programming Select the correct answer from above options...
asked Feb 15, 2022 in Education by JackTerrance
...