For this program reads the first 11 characters

Assignment Help C/C++ Programming
Reference no: EM13165441

E main for this program reads the first 11 characters from input, saving them. It then reads 26 short integers into |vals|, and passes them and the characters to EmbedWatermark, which subtly alters the contents of vals to contain the characters. After EmbedWatermark returns, main checks that no value in |vals| has changed by more than 7. (Note this would be the case if the bottom three bits had been changed, but no other bits.) The main then passes a copy of |vals| to PrintWatermark, which prints out the original characters by extracting them from |vals|, with no other data needed. The point of the exercise is to elegantly pack the bits of the chars into the LSBs of the values, and then unpack them, as a means of learning bitwise operations. But, it also shows how subtle "watermarks" can be embedded in data via small adjustments to its LSBs. Image data, in particular, is suitable for this, and watermarks are sometimes used to identify different copies of an image for copyright purposes. For the files below, nter code for PackChars.c #include #include #define NUM_VALS 26 #define NUM_CHARS 11 #define MAX_DIFF 7 #define BITS_PER_CHAR 7 #define LSBS 3 int main() { short *vals = calloc(NUM_VALS, sizeof(short)); char msg[NUM_CHARS]; int i, diff; short copy[NUM_VALS]; for (i = 0; i < NUM_CHARS; i++) msg[i] = getchar(); for (i = 0; i < NUM_VALS; i++) { scanf("%hd", &vals[i]); copy[i] = vals[i]; } EmbedWatermark(vals, msg); for (i = 0; i < NUM_CHARS; i++) msg[i] = 0; for (i = 0; i < NUM_VALS; i++) { diff = vals[i] - copy[i]; if (diff > MAX_DIFF || diff < -MAX_DIFF) printf("Val %d differs too much\n", i); copy[i] = vals[i]; } PrintWatermark(copy); } Test Cases: Test 1 Input Sample Data -32768 32767 -1 2 3 13345 0 12345 1023 -1022 32766 -32767 42 8192 -2 -3 -4 -1 1 2 3 1 30333 0 1023 32767 -32768 Output Sample Data

Reference no: EM13165441

Questions Cloud

Estimate of the temperature at which this solution : glycerol has a density of and a molecular weight of. If mL are mixed with a kg of water, what is a good estimate of the temperature at which this solution with freeze?
Process cost system to record the costs of processing : HomeStyle Soup Co. uses a process cost system to record the costs of processing soup, which requires the cooking and filling processes. Materials are entered from the cooking process at the beginning of the filling process.
Find the amount of heat transferred from the water : A 486 mL sample of water was cooled from 50.0°C to 10.0°C. Assuming a specific heat of 4.184 J/K g and a density of 1.00 g/mL, find the amount of heat transferred from the water to the surroundings.
What will be the equilibrium concentration of co : what will be the equilibrium concentration of CO.
For this program reads the first 11 characters : E main for this program reads the first 11 characters from input, saving them. It then reads 26 short integers into |vals|, and passes them and the characters to EmbedWatermark, which subtly alters the contents of vals to contain the characters. A..
Calculate and display the number of units of electricity : The manager of PG&E wants a program that calculates a customer's electric bill. He will enter the current and previous meter readings.
Jerry has done some analysis : Jerry has done some analysis about the profit ability of the bicycle shop. If Jerry builds the large bicycle shop, he will earn $60,000 if the market is good, but he will lose $40,000 if the market is bad
Design a 8m x 32 bit memory board : design a 8M x 32 bit memory board. You may use only 256K x 8 bit RAM chips with full parallel addressing.
Create a book class : Create a Book class. In addition to properties of author and isbn, with setters/getters, the Book should override Object's base method "boolean equals(Object)" and have a "boolean validate()" method.

Reviews

Write a Review

C/C++ Programming Questions & Answers

  Display the array, the average and the number of days above

Write a program that stores the daily temperatures for the month of April in an array name dailytemp. Calculate the average temperature for the month and the count the number of days that the daily temperature was above the average.

  Whitewater high school has contracted

Whitewater High School has contracted you to write a program that will read a file of student names and test scores in the formation FIRST NAME LAST NAME: SCORE1 SCORE2 SCORE3, where each of the scores is an integer

  Dynamically allocates an array large enough

Write a program that dynamically allocates an array large enough to hold a number of test score. The size of the array should be input by the user

  Define a class called plot that has private members of lengt

Define a class called Plot that has private members of length and width. Include a constructor and a public function that calculates the area and the length of the boundary of the field.

  Integer arguments representing feet

A constructor that will take a single integer argument representing a whole number of feet • A constructor that will take two integer arguments representing feet and inches respectively • A constructor that will take three integer arguments represent..

  Write song playlist class-object-oriented design principles

Write a song playlist class in C++ called "PlayList" using object-oriented design principles. The playlist should support the following ADT.The implementation should be based on an array of strings to store the song titles.

  Write a scanf statement to read in one number (int

1) Write a scanf statement to read in one number (int), and another statement to print out that number.

  Implement the vector class using inheritance

Is it better to implement the Vector class using inheritance (is-a relationship) or composition (has-a relationship). In other word, which one of the following gives a better implementation?

  Two types of constructors

Explain what constructors do and when they are executed. Explain the two types of constructors. Provide an example class that includes both types of constructor functions and demonstrate how an object would be instantiated using both types of constru..

  Write a c program that asks for and reads in two integers

Write a C program that asks for and reads in two integers and then reports if one is a multiple of the other.

  Make 2-dimensional array

make 2-dimensional array a bit of life and bringing them from the abstract to the concrete realms

  50 element array of integers with random numbers

write a java code to instantiate and initialize a 50 element array of integers with random numbers in the range of 45 through 256 inclusive.

Free Assignment Quote

Assured A++ Grade

Get guaranteed satisfaction & time on delivery in every assignment order you paid with us! We ensure premium quality solution document along with free turntin report!

All rights reserved! Copyrights ©2019-2020 ExpertsMind IT Educational Pvt Ltd