C++ Questions!!! 1) [3 points] The most common logical operators are and , or ,
ID: 3930859 • Letter: C
Question
C++ Questions!!!
1) [3 points] The most common logical operators are and, or, and not, but there are other ones. Research and complete truth tables for the following operators:
a) Exclusive or (XOR)
“xor” operator truth table
Left side
Right side
Result
b) Implication (®)
“implication” operator truth table
Left side
Right side
Result
c) Biconditional («)
“biconditional” operator truth table
Left side
Right side
Result
2) [4 points] What will the following program segments print?
a)
int x = 1;
while (x < 10);
x = x + 1;
cout << x;
b)
int x = 1;
while (x < 10)
x = x + 1;
cout << x;
c)
for (int count = 1; count <= 10; count++)
{
cout << ++count << “ “;
}
d)
for (int row = 1; row <= 3; row++)
{
cout << “ $”;
for (int digit = 1; digit <= 4; digit++)
cout << ‘9’;
}
3) [12 points] List any syntax or logic errors in the following program segments.
a)
int num1 = 0, num2 = 10, result;
num = num + 1;
result = ++(num1 + num2);
cout << num1 << “ “ << num2 << “ “ << result;
b)
int num1, num2;
char again;
while ((again == ‘y’) || (again == ‘Y’))
cout << “Enter two numbers: “;
cin >> num1 >> num2;
cout << “Their sum is “ << (num1 + num2) << endl;
cout << “Do you want to do this again? “;
cin >> again;
c)
int num, bigNum, power, count;
cout << “Enter an integer: “;
cin >> num;
cout << “What power do you want it raised to? “;
cin >> power;
bigNum = num;
while (count++ < power);
bigNum *= num;
cout << “The result is “ << bigNum << endl;
d)
int numCount, total;
double average;
cout << “How many numbers do you want to average? “;
cin >> numCount;
for (int count = 0; count < numCount; count++)
{
int num;
cout << “Enter a number: “;
cin >> num;
total = total + num;
count = count + 1;
}
average = total / numCount;
cout << “The average is << average << endl;
4) [6 points] What is the difference between a void function and a value function? Give an example of each.
a) Difference
b) void function example
c) value function example
“xor” operator truth table
Left side
Right side
Result
Explanation / Answer
INPUTS
OUTPUT
LEFT SIDE
RIGHT SIDE
RESULT(XOR)
0
0
0
0
1
1
1
0
1
1
1
0
INPUTS
OUTPUT(IMPLICATION)
LEFT SIDE/P
RIGHT SIDE/Q
RESULT(P->Q)
(Q->P)
T
T
T
T
T
F
F
T
F
T
T
F
F
F
T
T
INPUTS
OUTPUT(BICONDITIONAL)
LEFT SIDE/P
RIGHT SIDE/Q
RESULT(P<-->Q)
T
T
T
T
F
F
F
T
F
F
F
T
INPUTS
OUTPUT
LEFT SIDE
RIGHT SIDE
RESULT(XOR)
0
0
0
0
1
1
1
0
1
1
1
0
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.