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;
}
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 the array implemention of binary search tree.
Write the following functions :
1)insert
2)delete
3)search
4)display
Note:
No global declarations
Test run in main
Write a program in c++ that initiative an array of given 10 real numbers. The program should sort the number in awaiting / descending order using bubble sort method. It should print the given list as well as sorted list
The tap code, sometimes called the knock code, is a way to encode text messages on a letter-by- letter basis in a very simple way. Tap code has been one of the most basic communication protocols and still used to convey SOS messages and other urgent communication. The tap code uses a 5×5 grid of letters representing all the English alphabets, see Figure 1. To communicate the word "water", the cipher would be the following (with the pause between each number in a pair being shorter (single space) than the pause between letters (two spaces)),
Your task is to design a program that can
i) convert any given string into a Tap code sequence
Prototype: char* convertToTapCode(char*)
ii) and A Tap code sequence to a string (char*)
Prototype: char* convertToString(char*)
Note: You are not authorized to use string data type; however, you can use char*
Addition of Big Integer
In this problem, you have to take two char arrays of numbers (e.g., “1203009954” and
“109876201453”) from the user and add these two numbers and store answer in a third char array digit by digit (“111079211407”).
char* additionOfBigInteger(char * Num1, char* Num2)
Subtraction of Big Integer
In this problem, you have to take two char arrays of numbers (e.g., and “1203009954”
“109876201453”) from the user and subtract these two numbers and store answer in a third char array digit by digit (“-108673191499”).
char* subtractionOfBigInteger(char * Num1, char* Num2)
Multiplication of Big Integer
In this problem, you have to take two char arrays of numbers (e.g., and “1203009954”
“109876201453”) from the user and multiply these two numbers and store answer in a third char array digit by digit (“132182164055668263162”).
char* multiplicationOfBigInteger(char * Num1, char* Num2)
Write a C++ recursive function PrintPattern1 to print following pattern using recursion. No
loops allowed whatsoever, and you can write other helping (recursive) functions. For example, calling your function with these argument PrintPattern1(1,10) should print following pattern. Your function prototype must be as follows:
void PrintPattern1(int start, int end);
pattern:
*
*
*
*
*
*
*
A student is given a specific alphabet T in 2D and would have to output the alphabet T and make it rotate in 360 degrees clockwise.