
#include <iostream>
#include <bitset>
using namespace std;
int main()
{
unsigned int x = 0b01101100;
unsigned int y = 0b1111110;
unsigned int z = 0x12345678;
unsigned int e = 0x7;
unsigned int w = 0x87654321;
unsigned int m = 0x123;
int Q1, Q2, Q3, Q4;
Q1 = x & y;
cout << bitset<8> (Q1) <<
endl;
Q2 = ~(x | y);
cout << bitset<8> (Q2) <<
endl;
Q3 = (z << e);
cout << hex << (Q2) << endl;
Q4 = w ^ m;
cout << hex << (Q4) << endl;
return 0;
}
Note: Here is the working code, you forgot to include bitset header, bitset class comes from <bitset> header. So you'll have to use #include <bitset> right under #include <iostream>
How can I fix that ? Can you please explain clearly ? main.cpp 2 3 using...
I know the right answers by using a compiler. However, can you please explain each step and how you get the correct answer. Thank you in advance. Output: E = 1 F = 7 G = 11 H = 14 W = 5 X = 6 Problem 7 #include <iostream> #include <cmath> using namespace std; void F1(int,int,int,int&); void F2(int,int&,int&,int&); int main ( void ) { int E=1,F=2,G=3,H=4,W=5,X=6; F1(E,F,G,H); F2(E,F,G,H); cout << "E = " << E <<...
16 Points) Question 3 Write down the outputs of the following program into the provided table include <iostream> using namespace std; void fun I(int a); int fun2(int a, int b); int x-3: int main) int x-1,y 0,z-2; x-fun2(y,z); cout sx fun 1 (z); cout (#xtytz(endl; y-fun2(x,x); cout <exty+zscendl; system("pause"); void fun 1 (int a) int fun2(int a, int b) int static c2; return atx;
16 Points) Question 3 Write down the outputs of the following program into the provided table...
Can you help me explain how fork, getpid(), cout work in this code? I got a quiz today which asked me how many times cout and fork() is executed. #include <iostream> #include <unistd.h> using namespace std; int main ( int argc, char *argv [] ) { int pid; cout << getpid()<<endl; pid = fork(); if (pid == 0) { cout << getpid() <<endl; fork(); cout << getpid()<<endl; fork(); cout << getpid()<<endl; } return 0; }
Question 19 4 pts Using the program below, please complete the program by adding 2 functions as follow: 1. A function named getAverage that calculates and returns the Average. 2. A function named getMaximum that returns the maximum of the three numbers. Make sure to use the proper data types for all variables and functions. #include <iostream> using namespace std; //function getAverage //function getMaximum int main(int argc, char** argv) { int x, y, z; cout << "Enter three whole numbers:...
Given list.h, main.cpp, i need to write list.cpp. having a lot of problems. please help. list.h: ////////////////////////////////////////////////////////////////////////// #ifndef LIST_H #define LIST_H ////////////////////////////////////////////////////////////////////////// namespace CS170 { struct node { int value; node *next; }; class list { public: // Constructor for list. Creates an empty list list(); /* Destructor for list. Empty the list and release the allocated memory */ ~list(); // Prints out the values contained in the list void print_list() const; // Returns the current size of the list...
2. What is the value of x alter the following code is executed # include<iostream> using namespace std; int main int t-0, c- 0,x-3; while (c < 4) t=t+x; cout << x return 0; a) 3 b) 21 c) 24 d) 48 3. What is the output of the following code? # include<iostream> using namespace std; int main0 int a- 3; for (int i 5; i >0; i) a a+i cout << a << “ “ return 0; d) 8...
Hi I am using Repl.it, could anyone help fix the errors?
Instruction:
main.cpp
#include <iostream>
#include <cstdlib>
#include "InvItem.h"
using namespace std;
int main() {
InvItem a;
string description, idNumber;
// read in two strings
getline(cin, description);
getline(cin, idNumber);
// store properties in the object
a.setDescription(description);
a.setIDNumber(idNumber);
// print out the properties of the object
cout << a.getDescription() << endl;
cout << a.getIDNumber() << endl;
}
---------------------------------------------------------------
invltem.h
#ifndef INVITEM_H
#define INVITEM_H
#include<string>
using std::string;
class...
Fix the code to print the result[] array properly:
1 #include <iostream> 2 3 using namespace std; 4 5 void printArray(int array 7 for(inti= 0: i < 2;i++) cout くく array[i] << " ". 10 12 int mainO 13 14 int firstArray[2]10,20}; 16 int resultr21 17 int x; 18 19 II take input for second array 20 cin >>x 21 secondArray[0]-x; 22 secondarrayL1」-X+15 ; // Add elements 23 24 result0]- firstArray[0] + secondArray [0]; 25 result [1]- firstArray[1] + secondArray[1];...
C++
how can I fix these errors
this is my code
main.cpp
#include "SpecialArray.h"
#include <iostream>
#include <fstream>
#include <string>
using namespace std;
int measureElementsPerLine(ifstream& inFile) {
// Add your code here.
string line;
getline(inFile, line);
int sp = 0;
for (int i = 0; i < line.size(); i++)
{
if (line[i] == ' ')
sp++;
}
sp++;
return sp;
}
int measureLines(ifstream& inFile) {
// Add your code here.
string line;
int n = 0;
while (!inFile.eof())
{
getline(inFile,...
C++
1.
A?B?C?D? which one is correct
2.
3A, 3B
#include<iostream> using namespace std; void swap0(int* ptri, int* ptr2) { int *temp; temp = ptr1; ptr1 = ptr2; ptr2 = temp; void swap1(int ptri, int ptr2){ int temp; temp = ptri; ptr1 = ptr2; ptr2 = temp; portion void swap2(int *&ptri, int *&ptr2){ int* temp; temp = ptr1; ptr1 = ptr2; ptr2 = temp; void swap3(int &ptri, int &ptr2) { int temp; temp = ptr1; ptr1 = ptr2; ptr2 =...