Please complete the following problem in C. No source code is provided.
The left-shift operator can be used to pack four character values into a four-byte unsigned int variable. Write a program that inputs four characters from the keyboard and passes them to function packCharacters. To pack four characters into an unsigned int variable, assign the first character to the unsigned int variable, shift the unsigned int variable left by 8 bit positions and combine the unsigned variable with the second character using the bitwise inclusive OR operator. Repeat this process for the third and fourth characters. The program should output the characters in their bit format before and after they’re packed into the unsigned int to prove that the characters are in fact packed correctly in the unsigned int variable.
Packed Characters in an Integer:
/*Source Code*/
#include<stdio.h>
unsigned packCharacters(unsigned c1, char c2);
void display(unsigned val);
int main(void)
{
char a;
char b;
char d;
char e;
unsigned result;
unsigned result1;
unsigned result2;
printf("Enter any four characters:\n\n");
printf("Enter the %s character :", "first");
scanf("%c", &a);
getchar();
printf("Enter the %s character :", "second");
scanf("%c", &b);
getchar();
printf("Enter the %s character :", "third");
scanf("%c", &d);
getchar();
printf("Enter the %s character :", "fourth");
scanf("%c", &e);
getchar();
printf("\nRepresentation of '%c' in bits as an unsigned integer is:\n", a);
display(a);
printf("\nRepresentation of '%c' in bits as an unsigned integer is:\n", b);
display(b);
printf("\nRepresentation of '%c' in bits as an unsigned integer is:\n", d);
display(d);
printf("\nRepresentation of '%c' in bits as an unsigned integer is:\n", e);
display(e);
unsigned ch = a;
result = packCharacters(ch, b);
result1 = packCharacters(result, d);
result2 = packCharacters(result1, e);
printf("\nRepresentation of '%c\''%c\''%c\' and '%c\'"
"packed in an unsigned integer is:\n", a, b, d, e);
display(result2);
getchar();
return 0;
}
unsigned packCharacters(unsigned c1, char c2)
{
unsigned pack = c1;
pack <<= 8;
pack |= c2;
return pack;
}
void display(unsigned val)
{
unsigned c;
unsigned mask = 1 << 31;
printf("%7u = ", val);
for (c = 1; c <= 32; c++)
{
val & mask ? putchar('1') : putchar('0');
val <<= 1;
if (c % 8 == 0)
{
printf(" ");
}
}
putchar('\n');
}
Sample Design of Output:

Please complete the following problem in C. No source code is provided. The left-shift operator can...
The left-shift operator can be used to pack two character values
into an unsigned integer variable. Write a program that inputs two
characters from the keyboard and passes them to function
packCharacters. To pack two characters into an unsigned integer
variable, assign the first character to the unsigned variable,
shift the unsigned variable left by 8- bit positions and combine
the unsigned variable with the second character using the bitwise
inclusive OR operator. The program should output the characters in...
(Packing Characters into an Integer) The left-shift operator can be used to pack four character values into a four-byte unsigned int variable. Write a program that inputs four characters from the keyboard and passes them to function packCharacters. To pack four characters into an unsigned int variable, assign the first character to the unsigned intvariable, shift the unsigned int variable left by 8 bit positions and combine the unsigned variable with the second character using the bitwise inclusive OR operator....
Edit, compile, and run the following programs on the UNIX shell: Write a program that takes in six commandline arguments and has four functions (described below) that use bitwise operators. The user should enter six space-separated commandline arguments: four characters (any ASCII character) followed by two integers. Anything else should print an error message telling the user what the correct input is and end the program. Convert the commandline input into "unsigned char" and "unsigned int" datatypes. Be careful with...
Please help me with the following C Programming project. I am providing the code I used which needs to be reworked to add the following requirements. Here is my code #include<stdio.h> char input; int main() { int i = 0; while (true){ scanf_s("%c", &input); if (input == 'X') break; printf("%c", input); } return 0; } Here are the requirements for the code plus and additional note what the code should have. Goals Understand the ASCII representation of character values. Understand...
please
write a C++ code
Problem A: Word Shadow Source file: shadow.cpp f or java, or.cj Input file: shadow.in in reality, when we read an English word we normally do not read every single letter of that word but rather the word's "shadow" recalls its pronunciation and meaning from our brain. The word's shadow consists of the same number of letters that compose the actual word with first and last letters (of the word) in their original positions while the...
lab3RGB.c file:
#include <stdio.h>
#define AlphaValue 100
int main() {
int r, g,b;
unsigned int rgb_pack;
int r_unpack, g_unpack,b_unpack;
int alpha = AlphaValue;
printf("enter R value (0~255): ");
scanf("%d",&r);
printf("enter G value (0~255): ");
scanf("%d",&g);
printf("enter B value (0~255): ");
scanf("%d",&b);
while(! (r<0 || g<0 || b <0) )
{
printf("A: %d\t", alpha); printBinary(alpha); printf("\n");
printf("R: %d\t", r); printBinary(r); printf("\n");
printf("G: %d\t", g); printBinary(g); printf("\n");
printf("B: %d\t", b); printBinary(b); printf("\n");
/* do the packing */
//printf("\nPacked: value %d\t", rgb_pack); printBinary(rgb_pack);printf("\n");...
Please Complete the following C Code with Comments explaining your solution and post a screenshot of it working. Summary: This project explores pattern matching techniques to find a pattern in a DNA sequence containing letters in the DNA alphabet {A, C, G, T}. For example, suppose we have a DNA sequence as follows: ATGACGATCTACGTATGGCAGCCACGCTTTTGATGTTAAGTCACACAGCCAAGTCA ACAAGGGCGACTTCATGATCTTTCCGCTCCGTTGGTGTAGGCCCGTGTTCAAATTC AATGGCTGATTGGAATTACCTTTGAAATACTCCAACCGACCGCCACGGCCAGGGT CCCGCTCGCTCTCTGTGGCCCTCCCACAAAACTCCGGTGAAAGTTGATTTGGACAC GGACCCAAAGCAGCGTAGATTATTCGAGCGTATTCGGTAGTCATTGAGGCCCCAA The pattern “AATGG” can be found at the beginning of the third line. Note that overlapping matches are counted individually. For example,...
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...
Please develop the following code using C programming and using the specific functions, instructions and format given below. Again please use the functions given especially. Also don't copy any existing solution please write your own code. This is the first part of a series of two labs (Lab 7 and Lab 8) that will complete an implementation for a board-type game called Reversi (also called Othello). The goal of this lab is to write code that sets up the input...
This C++ Program consists of: operator overloading, as well as experience with managing dynamic memory allocation inside a class. Task One common limitation of programming languages is that the built-in types are limited to smaller finite ranges of storage. For instance, the built-in int type in C++ is 4 bytes in most systems today, allowing for about 4 billion different numbers. The regular int splits this range between positive and negative numbers, but even an unsigned int (assuming 4 bytes)...