Make a C++ program that will input a number and display the sum of the numbers from 1 to the input number using do while loop.
Each student would have to output the assigned Character using Java or C++ and make it rotate in 360 degrees clockwise
How to execute this using vector
#include <iostream>
bool doesexists(int array[], int toseaarch, int size);
const short int SIZE = 10;
int main() {
int myarray[SIZE], distinct_ctr = 0, index = 0;
std::cout << "Enter 10 numbers: ";
for (index = 0; index < SIZE; index++) {
int tmp;
std::cin >> tmp;
if (!doesexists(myarray, tmp, SIZE)) {
myarray[distinct_ctr] = tmp;
distinct_ctr++;
}
}
std::cout << "distinct numbers are: ";
for (index = 0; index < distinct_ctr; index++)
std::cout << myarray[index] << " ";
std::cout << "\n";
return 0;
}
bool doesexists(int array[], int toseaarch, int size) {
for (int index = 0; index < size; index++) {
if (toseaarch == array[index])
return true;
}
return false;
}
write a program that calculates and prints the monthly paycheck for an employee. The net pay is calculated after taking the following deductions:
Federal Income Tax: 15%
State Tax: 3.5%
Social Security Tax: 5.75%
Medicare/Medicaid Tax: 2.75%
Pension Plan: 5%
Health Insurance: $75.00
Simplify the following functions using a K-map
a. F(X, Y) = m2 + m3
b. F(X, Y) = X + X’Y
c. F(X, Y) = X’ + XY’
d. F(X, Y, Z) = m0 + m2 + m5 + m7
e. F(X, Y,Z) = X’Y’Z’ + X’YZ + XY’Z + XYZ
f. F(X,Y, Z) = π ( 0, 2, 5,7)
g. F(X, Y, Z) = XY’Z + X’ + Z + Y’Z’
h. F(W, X, Y, Z) = X’ Y’Z’ + XYZ’ + WXY + W’X’Y’ + WZ
i. F(W, X, Y, Z) = X’ + XZ’ + WX’Y + W’Y’ + WZ
10 11 12 13 14 15 16 17 18 19
20 21 22 23 24 25 26 27 28 29
30 31 32 33 34 35 36 37 38 39
40 41 42 43 44 45 46 47 48 49
Input Combination
by CodeChum Admin
We’ve tried adding together integers, so how about adding characters as well? Well we really don't know how to create a variable that holds the combined characters (at least for now) so let's just print them together in 1 string instead.
Instructions:
Input two characters in one line, separated by a space.
Make the strings be printed out like it’s concatenated (or combined) by printing it without spaces in between. Refer to the sample output for your reference.
Input
A line containing two characters separated by a space.
A·B
Output
A line containing two characters.
AB
Integer Pairing
by CodeChum Admin
Now this one's a tad bit tricky, but you can definitely do it!
Instructions:
Input five integers in one line, with each integer separated by a space.
Add the 1st and 2nd integers together and store the sum inside a variable.
Add the 3rd and 4th integers together and store the sum inside a variable.
Multiply the two sums and raise the product result to the power of the 5th integer.
Print out the result.
Input
A line containing five integers separated by a space.
1·2·3·4·5
Output
A line containing an integer.
4084101
How to execute this using vector
#include <cmath>
#include <iostream>
const short int SIZE = 10;
double mean(const double x[], int size);
// Compute the deviation of double values
double deviation(const double x[], int size);
int main() {
double myarray[SIZE];
std::cout << "Enter the number: ";
for (int index = 0; index < SIZE; index++)
std::cin >> myarray[index];
std::cout << "The mean is " << mean(myarray, SIZE) << ".\n";
std::cout << "The standard deviation is " << deviation(myarray, SIZE)
<< ".\n";
return 0;
}
double mean(const double x[], int size) {
double total = 0;
for (int index = 0; index < size; index++)
total += x[index];
return total / size;
}
double deviation(const double x[], int size) {
double themean = mean(x, size);
double total = 0;
for (int index = 0; index < size; index++) {
total += pow(x[index] - themean, 2);
}
return sqrt(total / size - 1);
}
How to execute this using vector
#include <cstdlib>
#include <ctime>
#include <iostream>
int main() {
int dice[6] = {0};
srand(time(0));
for (int ctr = 0; ctr < 10000; ctr++) {
switch ((rand() % 6) + 1) {
case 1:
dice[0] += 1;
break;
case 2:
dice[1] += 1;
break;
case 3:
dice[2] += 1;
break;
case 4:
dice[3] += 1;
break;
case 5:
dice[4] += 1;
break;
case 6:
dice[5] += 1;
break;
}
}
for (int index = 0; index < 6; index++)
std::cout << index + 1 << " appears " << dice[index] << " time/s\n";
return 0;
}