What is the output of the following C++ code? #include #include using namespace std; template class A { T x; U y; V z; }; int main() { A a; A b; cout << sizeof(a) << endl; cout << sizeof(b) << endl; return 0; }
Q: Write a function named “HasDashDashOnBothEnds” that accepts 2 parameters of the same as command line…
A: #include <iostream>using namespace std; bool HasDashDashOnBothEnds(int count, char**…
Q: Write a C++ program that will prompt the user for the size of a list of integers. Your program will…
A: The Answer is
Q: Write a complete C++ program which consists of two parts. Part 1. Write a function which counts the…
A:
Q: What will be the output of the following C++ code? #include #include using namespace std; class B {…
A: Classes in C++: A user defined data type that works as an object. A class is used to lay down the…
Q: Q6: Write a program in C++ that contains overloaded functions with name OvOperation(). When the main…
A: Task: write a c++ program that overloads an operator and do the required operation. all code and…
Q: Question 4 We consider the the following code: #include using namespace std; void add(int i, int…
A: Here in main() function A=1 B=2 C=3 D=1.1 We call add(A,B); => add(1,2) void add(int i,int…
Q: Define a generic function called CheckOrder() that checks if four items are in ascending, neither,…
A: Approach: Include necessary header files define a generic method CheckOrder to pass different types…
Q: Write a C function called ints2int_ptrs which takes two parameters: an array of integers (parameter…
A: Step 1 : Start Step 2 : Define a function ints2int_ptrs() which takes an array arr and a variable n…
Q: Consider the following function interface: void short_and_long(char **p, int n, int *short, int…
A: #include <stdio.h> // Assuming all strings terminate with '\0' void short_and_long(char** p,…
Q: What is the output of the following C++ code? #include #include using namespace std; template…
A: Given: What is the output of the following C++ code? #include<iostream>…
Q: QUESTION 3 Suppose the following declarations appear in the mainfunction of a C++ program: string…
A: ANS -- 3:- Correct option -- 1. void approvedFunds(string courseP, string nameP, string & dateP,…
Q: (13.)Write a function slope(x1, y1, x2, y2) that returns the slope of the line through the points…
A: def slope(x1,y1,x2,y2): return (y2-y1)/(x2-x1)…
Q: Write two regular c-type function templates called returnMinimum and returnMaximum that returns the…
A: //included headers#include<iostream>//mention the namespaceusing namespace std; //this problem…
Q: Write a C function called printBetween that accepts an array of floating point numbers , an integer…
A:
Q: in c++ write a code that: Define an enumeration type triangleType that has the values scalene,…
A: C++ is an efficacious general-purpose programming language. It can be used to elaborate on operating…
Q: def myfun ( x: Int, if x 0)': string) : String - { y + x, toString } else { myfun( x - 2 , "world" )…
A: Here we write answer of all the 6 Question marks:…
Q: Solution in JS Write a function that inserts a white space between every instance of a lower…
A: Algorithm - Take input from user. Now use the below logic - return…
Q: Consider the following program written in C syntax: void swap(int a, int b) { int temp;…
A: For the following program- void swap(int a, int b) { int temp; temp = a; a = b; b =…
Q: What is the output of the following C++ code? #include using namespace std; class X { int m;…
A: Given the C++ program, the output of that program is given below with explanation.
Q: Write a swap function, that swaps the values of two variables in main, but use pointers instead of…
A: Please refer to the following steps for the complete solution to the problem above.
Q: What is the output of the following C++ code? #include #include using namespace std; template class…
A: Given, Programming language = C++ Code: #include<iostream> #include<stdlib.h>…
Q: Q2. A Technician Engineer in a District Assembly wants to issue only even-numbered stalls to market…
A:
Q: Write a C++ Program using classes, functions (recursive and otherwise), arrays and other C++…
A: Program Plan: Define Counter class to count the vowels, letters and punctuations in a file. Define…
Q: Write the output of the following C++ code? #include using namespace std; class rect { int x, y;…
A: Que. Write the output of the following C++ code? Ans. Given, Programming language = C++ Code:…
Q: Please write a full code in JAVA for this: A function foo has k integers as input arguments,…
A: #include #include #include #include 57 /* concatenate n copies of src into dest */ /* returns dest…
Q: Write in c++ a Template function body called swap( ) to swap the values of the two values of…
A: A template is used to create generic classes and generic functions for executing any type of data.…
Q: Write a C++ Program using classes, functions (recursive and otherwise), arrays and other C++…
A: #include<iostream> #include <algorithm> #include<fstream> #include<string>…
Q: Please use c++ .Turn the plus () function in Question 2 into a template. Create a template…
A: Code: #include <iostream> template<typename T>T plus(T p1,T p2){ //c_str() converts…
Q: Discussion: Files with .h extension are called header files in C. These header files generally…
A: In C, files with the .h extension are known as header files. These header files typically contain…
Q: Assuming you have a c-string variable "location" with a size of 30, write a line of code that allows…
A: Note: we are only allowed to solve one question in one post. I am solving the first on here. To get…
Q: Write the C equivalent “train” function #void train(int*A, int*B, int*C, int k) train: add…
A: I have decoded the MIPS code and written all 11 instructions with a meaning along with the MIPS…
Q: In C++, write a function (named "templated_array_copy") that takes two parameters (two arrays of the…
A: PROGRAM INTRODUCTION: Include the required header files. Start definition of the function that…
Q: umber of space at the beginning of the line. (in Haskell) code: joinLine :: Line -> String
A: Modify the function joinLine so that it right align the line to lengthlineLen by adding the…
Q: can someone help me with this in C++ In this program, you must implement I/O operator overloading…
A: We need to update the definition of the Triangle and Square classes to add the declaration of the…
Q: 2. Identify the errors in the following template function headers a. template f(int a) b. template…
A: - We need to highlight the errors in the template headers.
Q: 10. What is the result of the following code in C++ ? (assume all #include and the unseen code is…
A: p points to array x then exchange values using pointer in the for loop to after exchanging value…
Q: #include #include #include #include #include "team.h" const int NUM_TEAMS = 16; void…
A: Answer: I have completed your function and also I have attached code and code screenshot.
Q: What is the output of the following C++ code? #include #include using namespace std; template class…
A: Given: What is the output of the following C++ code?…
Q: ould I get an example of a program writen in C that uses qsort() to sort its command line vector…
A: Could I get an example of a program writen in C that uses qsort() to sort its command line vector…
Q: Why has the value of x,y,z changed even though the change occurred inside the function ? -2, y-6,…
A: Calling a function can be done in two ways and are as follows Call by value Call by reference
Q: What do the keywords virtual and override do in C++?
A: Function overriding is redefinition of base class work in its inferred class with same mark i.e…
Q: In C++, write a function (named "templated_array_copy") that takes two parameters (two arrays of the…
A: void templated_array_copy(int source[2], int destination[3]){ //Find size which is smaller int…
Q: Write a C++ program using Selection Statements, Loop, Arrays, Structs, Pointers, Funtions, and OOP…
A: C++ program to filter number fro a given string
Q: Consider the following program written in C syntax: void swap(int a,int b){ int temp;…
A: Pass by value : This is defined as describing the variables that are passed on which means the…
Q: Give solution in C ++ Language with secreenshoot of source code. Part 01 In this task, you need to…
A: Since multiple questions have been posted at a single request, we will answer first question. If you…
Q: The topic is Booth's algorithm - Explain this C programming code - i have a seminar. //header files…
A: Booth's Multiplication Algorithm: Booth’s algorithm is a multiplication set of rules that multiplies…
Q: What will be the output of the following C++ function? #include using namespace std; template…
A: Given, Programming language = C++ Code: #include <iostream> using namespace std;…
Q: Q6: Write a program in C++ that contains overloaded functions with name Ov0peration(). When the main…
A: Function overloading happens when two or more functions have the same name but different arguments.…
Q: In C++, write a program that uses a function template called maximum to determine the larger of two…
A:
What is the output of the following C++ code?
#include<iostream>
#include<stdlib.h>
using namespace std;
template<class T, class U, class V=double>
class A
{
T x;
U y;
V z;
};
int main()
{
A<int, int> a;
A<double, double> b;
cout << sizeof(a) << endl;
cout << sizeof(b) << endl;
return 0;
}
Step by step
Solved in 3 steps with 2 images
- write the program in c# Create a class name Exponents and Write a function power(base , exponent) that takes 2 parameters of type ” int” that returns the value of base exponent. Base is nonzero positive integer while exponent is positive integer. Call this power method within function button_click of windows form class that reads integer values for base and exponent from user and performs the calculation written in the power method of Exponents class. If returned value is even it should display on label otherwise display it on textbox. Built-in functions are not allowed to use.(Assume label name lblDisplay and textbox name txtDisplay)Write a program in C++ that allows the user to enter the values to assign a card's suit (commonly implemented as an enumeration — Hearts, Clubs, Diamonds, Spades) from the keyboard. You cannot use a menu. Your program must read the user's choice directly into the card suit variable (of an enum type). (Note: You cannot overload operators for built-in types, but enumerations are, technically, user-defined types. Therefore you can overload input/output operators for them.) This proof of conceptapplication will help show your programming team that the bridge game you are designing can accept bids directly from the player without having to rely on a clumsy menu interface. An example program interaction might look something like this: $ ./suitenter.out Welcome to the Card Suit Entering Program!!! What is the suit of your card? hearts You have a heart! Don't wear it on your sleeve..! Another card? y What is the suit of your card? s So, you have a spade! Dig me a hole out back, won't you?…Write a program in C++ that allows the user to enter the values to assign a card's suit (commonly implemented as an enumeration — Hearts, Clubs, Diamonds, Spades) from the keyboard. You cannot use a menu. Your program must read the user's choice directly into the card suit variable (of an enum type). (Note: You cannot overload operators for built-in types, but enumerations are, technically, user-defined types. Therefore you can overload input/output operators for them.)
- CPS506 Lab 6 Haskell: Type classes and custom types Preamble In this lab you'll create a custom type in Haskell and make it an instance of several built-in Haskell type-classes. Getting Started The provided cabal project defines a module called Lab6. This module will define a custom type called DigitalTime. The DigitalTime type will be used to represent time as a 3-tuple of integers. One for hour, minute, and second, respectively. Thus, the type definition should look like this: data DigitalTime = DigitalTime (Int, Int, Int) Next, you will implement several type classes over this type. These type classes and their operations can be found below. Assume that the hour range is 1-12. Do not use 24h time. Type Classes to Implement Show: show DigitalTime (h, m, s) Print the time in the format "<hh:mm:ss>" Eq: (==) (DigitalTime (h1, m1, s1)) (DigitalTime (h2, m2, s2)) Two times are considered equal if they have the same hour, minute, and second values. Ord: (<=) (DigitalTime (h1, ml,…please code this for me in c++ using void, functions, loops, (basic c++ not complicated or highlevel please). I tried to code it myself but there are many mistakes I dont know how to fix so please write a similar one for me but it works. The question is only 1 but it has 2 parts (2 different functions that should be in one code) MY CODE: #include <iostream>using namespace std; int IsPalindrome(int p);void GCD(); int main (){ int choice; cout << "Please enter a choice: "<<endl; cout << "Enter one for IsPalindrome "<<endl; cout << "Enter 2 for GCD "<<endl; cout << "Enter 3 to exit the program "<<endl; cout << "Choice: "<<endl; cin >> choice; if (choice == 1) { int p; cout << "Please enter a 3 digit number: "<<endl; cin >> p; if(p%10==p/100) { cout<<p<<" is a palindrome " <<endl; } else {…This is in c++ The base class Pet has private data members petName, and petAge. The derived class Dog extends the Pet class and includes a private data member for dogBreed. Complete main() to: create a generic pet and print information using PrintInfo(). create a Dog pet, use PrintInfo() to print information, and add a statement to print the dog's breed using the GetBreed() function. main.cpp #include <iostream> #include<string> #include "Dog.h" using namespace std; int main() { string petName, dogName, dogBreed; int petAge, dogAge; Pet myPet; Dog myDog; getline(cin, petName); cin >> petAge; cin.ignore(); getline(cin, dogName); cin >> dogAge; cin.ignore(); getline(cin, dogBreed); // TODO: Create generic pet (using petName, petAge) and then call PrintInfo // TODO: Create dog pet (using dogName, dogAge, dogBreed) and then call PrintInfo // TODO: Use GetBreed(), to output the breed of the dog } Dog.cpp #include "Dog.h" #include…
- What is the output of the following C++ code? #include <iostream> using namespace std; class Base { public: int m; Base(int n=0) : m(n) { cout << "Base" << endl; } }; class Derived: public Base { public: double d; Derived(double de = 0.0) : d(de) { cout << "Derived" << endl; } }; int main() { cout << "Instantiating Base" << endl; Base cBase; cout << "Instantiating Derived" << endl; Derived cDerived; return 0; }What will be the evaluation results of each of the following expressionshown by GHCi ? Briefly explain. HASKELL a. > [(x,y) | x <- [1,2], y <- [4,5]]b. > [(y,x) | x <- [1,2], y <- [4,5]]We're going to explore the law of large numbers here with a dice rolling program. Seed the random number generator with the current time and then roll three 6-sided dice (often described as 3d6) a total of 1,000,000 times and keep track of the number of times each sum 3 - 18 occurs. Be sure to separate all functions and methods (if you chose to use a class or structure) into both the prototype and an implementation below the main. 1. Build a regular c-type function that returns a random number between 3 - 18. This will simulate a single roll of three dice. Use the prototype: int rollDice(void);2. In the main, roll the dice 1,000,000 times and tally up the results in an array. I DO NOT want each individual roll printed to screen. Let the index represent the number rolled and the value will represent the number of times that number has been rolled. For example, a[3] = 5357 a[4] = 14750...a[18] = 4981 This array set-up will mean that the result 3 occurred 5,357 times and the…
- This is C++. Please explain in details so I can understand the questions.What is the output of the following C++ program? #include <iostream>#include <string>using namespace std;class baseClass{public:void print() const;baseClass(string s = " ", int a = 0);//Postcondition: str = s; x = a;protected:int x;private:string str;};class derivedClass: public baseClass{public:void print() const;derivedClass(string s = "", int a = 0, int b = 0);//Postcondition: str = s; x = a; y = b;private:int y;};int main(){baseClass baseObject("This is the base class", 2);derivedClass derivedObject("DDDDDD", 3, 7);baseObject.print();derivedObject.print();system("pause");return 0;}void baseClass::print() const{cout << x << " " << str << endl;}baseClass::baseClass(string s, int a){str = s;x = a;}void derivedClass::print() const{cout << "Derived class: " << y << endl;baseClass::print();}derivedClass::derivedClass(string s, int a, int b) :baseClass("Hello…in c++ , fix all bugs or mistakes in code and explain in comments what was wrong and how you fix it (there can be problems with semi-columns, curly braces, included libraries, wrong usage of functions, inproper conversion of datatypes and etc.) Comment all changes in code and show the outputprogramming paradigms Please write the following functions in Haskell. Please also write type declarations for each function, including type classes, wherever necessary. 1. Modify isGodzilla from today's lecture to isNum where the function accepts an integer as an input parameter and outputs True if this integer matches the number in the function. 2. Write a function fibList that uses the fib function from today's lecture. fibList accepts a number n as parameter and outputs a list of the numbers in the Fibonacci series up to n. Note that fibList will use a list comprehension involving fib. 3. Write a function justHighScores that takes the list generated as output of the gradeBook function and returns a list of students who score >= 95. Please use the isHighScorer function from today's lecture in justHighScores. You will also have to implement the gradeBook function discussed in class today. 4. Modify the function lastElement from today's lecture to getSecondLast. The function…