Help please New blank CC Win32 Console Application Name Task
Help please
New blank C/C++ Win32 Console Application Name: Task5 Solution name: COAL In the project Tasks implement all C/C++ functions which contain Inline Assembler instructions as full assembler procedures and place them in separate assembler module (in file with extension ASM). To enable full assembler support m the Visual Studio: In the Solution Explorer window right click on the project name Task5 and from the context menu select: Custom Build Rules... - for Visual Studio 2008 Build Customizations... - for Visual Studio 2010 and newer In the dialog that opens make sure to mark the checkbox for item: Microsoft Macro Assembler - for Visual Studio 2008 mask(.targets, .props) - for Visual Studio 2010 and newer Demonstrate assembler module by calling procedures from the C/C++r code. TASK Implement: Count the number of odd values (n mod 2 0) for each row. Suggested template for assembler module: - 586 - model flat, C -code Solution for Grade? PROC PUBLIC USES ... [LOCAL ...] ret SolutionForGrade7 ENDP ENDSolution
ow N: 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20
odd #s: 1 2 2 4 2 4 4 8 2 4 04 08 04 08 08 16 02 04 04 08 04
It appears the answer is always a power of 2. In fact, the following is true:
Our proof makes use of the binomial theorem and modular arithmetic. The binomial theorem says that
(1+x)N = SUMk=0 to N (N CHOOSE k) xk.
If we reduce the coefficients mod 2, then it\'s easy to show by induction on N that for N >= 0,
(1+x)2^N = (1+x2^N) [mod 2].
Thus:
(1+x)10 = (1+x)8 (1+x)2 = (1+x8)(1+x2) = 1 + x2 + x8 + x10 [mod 2].
Since the coefficients of these polynomials are equal [mod 2], using the binomial theorem we see that (10 CHOOSE k) is odd for k = 0, 2, 8, and 10; and it is even for all other k. Similarly, the product
(1+x)11 = (1+x8)(1+x2)(1+x1) [mod 2]
is a polynomial containing 8=23 terms, being the product of 3 factors with 2 choices in each.
In general, if N can be expressed as the sum of p distinct powers of 2, then (N CHOOSE k) will be odd for 2p values of k. But p is just the number of 1\'s in the binary expansion of N, and (N CHOOSE k) are the numbers in the N-th row
