write a function in C that swaps every other byte: for example,
Input: "badcfe”
Output: abcdef
I was thinking something like , where len would be two since I just want to swap values next to each other, but this doesnt work.
void
swap(char *p, int len) {
int i;
char tmp;
for(i = 0; i < len/2; i++) {
tmp = p[len-i-1];
p[len-i-1] = p[i];
p[i] = tmp;
}
}
void swap(char *p, int len) {
int i;
char tmp;
for(i = 0; i < len && i+1 < len; i+=2) {
tmp = p[i];
p[i] = p[i+1];
p[i+1] = tmp;
}
}
write a function in C that swaps every other byte: for example, Input: "badcfe” Output: abcdef...
Write a program in C++ that, given a seven-digit number, writes to a file every possible seven-letter corresponding to that number. There are 2187 (3 to the seventh power) such words. Include the numbers 0 and 1; just embed them in the words as a 0 and a 1. Example: one possibility for 5701679 would be: LR01OPW. Assume the user correctly enters only 7 digits (no ‘-‘). Read the user input into a char array. Use a recursive function to...
Write a python function called "get_sma", that takes two input arguments, similar to the example provided. First argument is the original prices of type list, and the 2nd input argument being the number of days we want to calculate SMA, like a 8 day sma or 35 day sma. This function should return a new list of sma price, based on the input day range, and should be able to handle any SMA calculation, like: sma200 for 200 days moving...
Please Update my C++ code: Implement array to replace for vector: Example --> input: 100 output: A 1000Pairs.txt looks like this: {100, A } {200, A } {300, B } {400, C } {500, D } {600, E } {700, F } {800, G } {900, H } {1000, I } {1100, J } {1200, K } {1300, L } {1400, M } {1500, N } {1600, O } {1700, P } {1800, Q } {1900, R } {2000, S...
Using C: Implement the function ranges that takes no input and prints the ranges (i.e., the minimum and maximum legal values) of the types char, short, int, long, and long long, both signed and unsigned. You should do this by printing appropriate constants defined in the header file /usr/include/limits.h (this is why hw1.c starts with #include <limits.h>). This should print something like: signed char minimum value: -128 maximum value: 127 unsigned char minimum value: 0 maximum value: 255 signed short...
"Controlling complexity is the essence of computer programming." Write a program that uses the C++ string functionality to count the number of vowels in this phrase. Q7. Write a function bool xor(bool A, bool B) which returns the Exclusive OR of boolean input variables A and B. Test your function by printing out the full truth table of the function. Q8. Write a method swap(char_all, int i, int i) which swaps element i and element j of a given character...
This assignment tests your ability to write C programs that handle keyboard input, formatted console output, and input/output with text files. The program also requires that you use ctype functions to deal with the logic. In this program, you will input from the user two characters, which should both be letters where the second letter > the first letter. You will then input a file character-by-character and output those letters that fall between the two characters (inclusively) to an output...
I NEED HELP WITH DEBUGGING A C PROGRAM! PLEASE HEAR ME
OUT AND READ THIS. I just have to explain a lot so you understand
how the program should work.
In C programming, write a simple program to
take a text file as input and encrypt/decrypt it by reading the
text bit by bit, and swap the bits if it is specified by the first
line of the text file to do so (will explain below, and please let
me...
This question has been asked before but the responses have been wrong. Please do not copy and paste their answers. Currently the program opens a file and reads every byte in the file and write both the ASCII hex value for that byte as well as it’s printable character to standard output with non-printable characters printing a "." Now, I want have an option where the program prints in binary instead of hex by typing "-b" at the command line....
write C code that uses pointers, arrays, and C strings. 3. Write a function called pow_xy. The function should be passed 2 parameters, as illustrated in the prototype below. int pow_xy(int *xptr, int y); Assuming that xptr contains the address of variable x, pow_xy should compute x to the y power, and store the result as the new value of x. The function should also return the result. Do not use the built-in C function pow. For the remaining problems,...
Language C++ (Please include a short description & Screenshot of output) Implement a Priority queue using a SORTED list. Use Quick sort after adding a new node. Example of quick sort below. Adopt to your program the code below. #include <iostream> void quickSort(int a[ ], int first, int last); int pivot(int a[], int first, int last); void swap(int& a, int& b); void swapNoTemp(int& a, int& b); void print(int array[], const int& N); using namespace std; int main() { int test[]...