Programming does not always happen smoothly, sometimes a lot of patience, devotion and perseverance are required to solve programming problems and stumbling blocks on your way of creating a new programming solution.While developing an application you might come across a number of programming questions the answers to which are not easy to be found. To spare yourself the trouble, submit your programming questions here and you will get programming answers within the shortest time period.

### Ask Your question

Need a fast expert's response?

Submit orderand get a quick answer at the best price

for any assignment or question with DETAILED EXPLANATIONS!

### Search & Filtering

Find 5 errors in the following program. Rewrite the program.

int main()

(

double temp:

cout<<”Enter temperature:`;

cin>>temp;

if(temp >= 20 && temp <=30)

cout<<”Outdoor Game\n”.

else

cout<”indoor game\n”;

return 0;

}

int main()

(

double temp:

cout<<”Enter temperature:`;

cin>>temp;

if(temp >= 20 && temp <=30)

cout<<”Outdoor Game\n”.

else

cout<”indoor game\n”;

return 0;

}

What does g(31415927) return, for the following function definition?

def g(x):

(q,d) = (1,0)

while q <= x:

(q,d) = (q*10,d+1)

return(d)

def g(x):

(q,d) = (1,0)

while q <= x:

(q,d) = (q*10,d+1)

return(d)

def g(x):

(q,d) = (1,0)

while q <= x:

(q,d) = (q*10,d+1)

return(d)

What does g(31415927) return, for the following function definition?

def g(x):

(q,d) = (1,0)

while q <= x:

(q,d) = (q*10,d+1)

return(d)

Consider the following function h.

def h(n):

f = 0

for i in range(1,n+1):

if n%i == 0:

f = f + 1

return(f%2 == 1)

The function h(n) given above returns True for a positive number n whenever:

n is a multiple of 2

n is a composite number

n is a prime number

n is a perfect square

def h(n):

f = 0

for i in range(1,n+1):

if n%i == 0:

f = f + 1

return(f%2 == 1)

The function h(n) given above returns True for a positive number n whenever:

n is a multiple of 2

n is a composite number

n is a prime number

n is a perfect square

What is the value of h(231,8) for the function below?

def h(m,n):

ans = 0

while (m >= n):

(ans,m) = (ans+1,m-n)

return(ans)

def h(m,n):

ans = 0

while (m >= n):

(ans,m) = (ans+1,m-n)

return(ans)

What does g(31415927)return for the following definition?

def g(x):

(q,d) = (1,0)

while q <= x:

(q,d) = (q*10,d+1)

return(d)

def g(x):

(q,d) = (1,0)

while q <= x:

(q,d) = (q*10,d+1)

return(d)

The following code defines a multimap associative container and inserts some initial values. Add code for a second multimap associative container and algorithm statements that search for duplicates in the original container and move those duplicate keys and values to the new container (deleting the entries from the original container).

#include <map>

using namespace std;

int main()

{

multimap< int, int, less< int > > container8;

container8.insert( make_pair ( 7, 24 ) );

container8.insert( make_pair ( 7, 16 ) );

container8.insert( make_pair ( 4, 56 ) );

container8.insert( make_pair ( 4, 72 ) );

container8.insert( make_pair ( 3, 17 ) );

container8.insert( make_pair ( 7, 41 ) );

container8.insert( make_pair ( 2, 12 ) );

container8.insert( make_pair ( 5, 67 ) );

}

#include <map>

using namespace std;

int main()

{

multimap< int, int, less< int > > container8;

container8.insert( make_pair ( 7, 24 ) );

container8.insert( make_pair ( 7, 16 ) );

container8.insert( make_pair ( 4, 56 ) );

container8.insert( make_pair ( 4, 72 ) );

container8.insert( make_pair ( 3, 17 ) );

container8.insert( make_pair ( 7, 41 ) );

container8.insert( make_pair ( 2, 12 ) );

container8.insert( make_pair ( 5, 67 ) );

}

Using the class “string” from the C++ standard library, write the statements to perform the following tasks.

(Do not write an entire C++ program.) Assume that there are two string variables containing words separated by one or more blanks with no special characters. Numbers within the strings are valid.

Compare string1 to string2 to determine if they have the same number of vowels (a,e,i,o,u).

Hint: Use the string method “find_first_of” in a loop for each string.

Make a copy of the longest word from the string1 and insert it into string2 after the first word. (Maintain blanks between all words in string2.)

Hint: Use the string methods “find” and “insert”.

(Do not write an entire C++ program.) Assume that there are two string variables containing words separated by one or more blanks with no special characters. Numbers within the strings are valid.

Compare string1 to string2 to determine if they have the same number of vowels (a,e,i,o,u).

Hint: Use the string method “find_first_of” in a loop for each string.

Make a copy of the longest word from the string1 and insert it into string2 after the first word. (Maintain blanks between all words in string2.)

Hint: Use the string methods “find” and “insert”.

Given the following Array class definition, write a new overloaded operator function for the ‘%’ (modulus) operator (i.e., return an array object that contains the remainders of divide operations between corresponding values in two array objects.) Write the code that would be required in the Array.cpp file. This new function must check for divide by 0.

E.g., array3 = array1 % array2;

class Array

{

public:

Array( int = 10 );

~Array( );

int getSize( ) const;

const Array &operator= ( const Array & );

bool operator==( const Array & ) const;

int &operator[ ]( int );

private:

int size; // Size of the array (number of elements)

int *ptr; // Pointer to the first element of the array

}

E.g., array3 = array1 % array2;

class Array

{

public:

Array( int = 10 );

~Array( );

int getSize( ) const;

const Array &operator= ( const Array & );

bool operator==( const Array & ) const;

int &operator[ ]( int );

private:

int size; // Size of the array (number of elements)

int *ptr; // Pointer to the first element of the array

}