C++
Write an expression that evaluates to true if and only if the C-string s equals the C-string “end”.
LANGUAGE: C++ CHALLENGE: Write an expression that evaluates to true if and only if the C-string s equals the C-string “end”.
Read MoreAssume that scotus is a two-dimensional character array that stores the family names (last names ) of the nine justices on the Supreme Court of the United States. Assume no name is longer than twenty characters. Assume that scotus has been initialized in alphabetical order. Write an expression whose value is the last name stored in the array .
LANGUAGE: C++ CHALLENGE: Assume that scotus is a two-dimensional character array that stores the family names (last names ) of the nine justices on the Supreme Court of the United States. Assume no name is longer than twenty characters. Assume that scotus has been initialized in alphabetical order. Write an expression whose value is the…
Read MoreDeclare and initialize a two-dimensional character array named “stooges” to store the names “moe”, “larry” and “curly” (in that order). Do not make the array any larger than it needs to be.
LANGUAGE: C++ CHALLENGE: Declare and initialize a two-dimensional character array named “stooges” to store the names “moe”, “larry” and “curly” (in that order). Do not make the array any larger than it needs to be.
Read MoreAssume the existence of a Window class with integer data members width and height. Overload the >> operator for the Window class — i.e., write a nonmember istream-returning function that accepts a reference to an istream object and a reference to a Window object and reads the next two values from the istream in to the width and height members respectively. Don’t forget to have the function return the proper value as well. Assume the operator has been declared a friend in the Window class .
LANGUAGE: C++ CHALLENGE: Assume the existence of a Window class with integer data members width and height. Overload the >> operator for the Window class — i.e., write a nonmember istream-returning function that accepts a reference to an istream object and a reference to a Window object and reads the next two values from the…
Read MoreAssume the existence of a Window class with integer data members width and height. Overload the << operator for the Window class -- i.e., write a nonmember ostream-returning function that accepts a reference to an ostream object and a constant reference to a Window object and sends the following to the ostream: 'a (width x height) window' (without the quotes and with width and height replaced by the actual width and height of the window. Thus for example, if the window had width=80 and height=20, << would send 'a (80 x 20) window' to the ostream.) Don't forget to have the function return the proper value as well. Assume the operator has been declared a friend in the Window class .
LANGUAGE: C++ CHALLENGE: Assume the existence of a Window class with integer data members width and height. Overload the << operator for the Window class — i.e., write a nonmember ostream-returning function that accepts a reference to an ostream object and a constant reference to a Window object and sends the following to the ostream:…
Read MoreWrite a fragment of code that reads a line of text (using getline) from standard input consisting of a last name followed by a first name (separated by exactly one blank), and prints out the first initial followed by a period then a blank then the full last name. Declare any necessary variables. (string processing)
LANGUAGE: C++ CHALLENGE: Write a fragment of code that reads a line of text (using getline) from standard input consisting of a last name followed by a first name (separated by exactly one blank), and prints out the first initial followed by a period then a blank then the full last name. Declare any necessary…
Read MoreDefine the following Window class : – integer data members, width and height – a constructor that accepts two integer parameters (width followed by height) and uses them to initialize the data members – a friend function, areSameSize, that accepts two Window objects and returns a boolean indicating if they are the same size. Two windows are the same size if the widths and heights match.
LANGUAGE: C++ CHALLENGE: Define the following Window class : – integer data members, width and height – a constructor that accepts two integer parameters (width followed by height) and uses them to initialize the data members – a friend function, areSameSize, that accepts two Window objects and returns a boolean indicating if they are the…
Read MoreAssume the existence of a File class with boolean data member, isValid, indicating the file is ready for I/O. Write a unary operator, !, that accepts a constant File reference, and returns true if the file is not ready for I/O and false otherwise.
LANGUAGE: C++ CHALLENGE: Assume the existence of a File class with boolean data member, isValid, indicating the file is ready for I/O. Write a unary operator, !, that accepts a constant File reference, and returns true if the file is not ready for I/O and false otherwise.
Read MoreWrite a function, sort, that accepts an array of integers, and the number of elements in the array and sorts the array in ascending order (basic sort)
LANGUAGE: C++ CHALLENGE: Write a function, sort, that accepts an array of integers, and the number of elements in the array and sorts the array in ascending order (basic sort)
Read MoreAssume that an vector of int named a has been declared with12 elements and that the integer variable k holds a value between 0 and 6. Assign 15 to the vector element whose index is k.
LANGUAGE: C++ CHALLENGE: Assume that an vector of int named a has been declared with 12 elements and that the integer variable k holds a value between 0 and 6. Assign 15 to the vector element whose index is k.
Read MoreGiven that an vector of int named a with 30 elements has been declared, assign 5 to its last element .
LANGUAGE: C++ CHALLENGE: Given that an vector of int named a with 30 elements has been declared, assign 5 to its last element.
Read MoreAssume that an vector named a, containing exactly five integers has been declared and initialized. Write a single statement that adds ten to the value stored in the first element of the vector.
LANGUAGE: C++ CHALLENGE: Assume that an vector named a, containing exactly five integers has been declared and initialized. Write a single statement that adds ten to the value stored in the first element of the vector.
Read More