Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Instructions: The questions consist of writing small portions of code or short a

ID: 441886 • Letter: I

Question

Instructions: The questions consist of writing small portions of code or short answers. The coding questions do not require a full program - only the portion described. The best approach is to write the code in Visual Studio (or Xcode or whatever program you are using) and then paste in only the portion required. 1) Create a for loop that counts from 100 down to 1. In the loop, print out each number. If the number is even, print "---Even". Use the appropriate printing commands (setw, precision, ext) to insure that the ---Even statements are indented exactly 7 characters from the left margin. Sample output: 100 ---Even 99 98 ---Even 2) Describe the difference between passing by reference and passing by value. Include in your discussion why you would choose one or the other, as well as example functions showing the difference (you should write two functions that clearly show the how each behaves). 3) This problem will require a bit of research. To better understand floating point numbers, research the IEEE 754 single-precision floating point format referred to as binary32. A good source of information can be found at http://en.wikipedia.org/wiki/Binary32. In your answer, describe the format in general (how many bits are used, how are the bits divided up in terms of what they mean). Then convert the number 0.124 to binary format and show the result in both binary and hexadecimal. 4) Write a function that takes a number as an argument and returns the number squared and cubed (i.e, given 5, the function would return 25 and 125, for example).

Explanation / Answer

Answer-1


for(i=100;i>=1;i--)
{
cout<<" "<<i;
if(i%2==0)
cout << setw(7)<<"Even";

}

Answer-2