CS 112: Course Policies Project 0

Hello, if you have any need, please feel free to consult us, this is my wechat: wx91due

Project 0: Exploring types, etc.

Objectives:

  1. Practice creating variables, printing values, printing locations of variables, and so on.

Step 1. Setup

  • Click on this assignment invitationhttps://classroom.github.com/a/hz4_ylIxand then "Accept this assignment".

  • Wait a few seconds and refresh the page. Refresh until the page says "You're ready to go!".

  • Click the link to see your new repo on github.com.

  • Click the green Code button, then SSH, and copy the link it shows.

  • In a terminal,

    • cd to the directory where you are putting all your CS112 assignments.

    • type:git clone <paste-the-contents-of-the-link-you-copied>

  • cdto the new directory containing your repo.

  • typecode .to start up Visual Studio Code in that directory.

  • Inspect the code you got in the assignment.

  • In the terminal, typemake

  • The code should compile and give you an executable called "tester". You can see if it is there by typingls 

  • Run the program: type./tester

  • You should get some basic output -- or at least it should not crash.

Step 2.

Infunctions.cpp, invars(), create aconstant unsigned integercalledBIG_NUMBER, initialized to 10 million.

Then, create a variable of typestringand initialize it to your name. (Note: you will have to#include <string>to make this work.)

Then, create a variable of typecharand initialize it to the first letter of your last name.

Then, create a variable of typedoubleand initialize it to the value 3.1415.

Then, create a variable of typebooland initialize it to false.

Then, create a variable of typelongand initialize it to 0.

Compile and run your code by typingmake testerin the terminal. NOTE: you'll get warnings about unused variables. Ignore them.

NOTE: at this point in the course, our tester program does not actually test the results in the output. However, when you submit your code to github, an automated testing script will run, which will test if the output is correct. If it isn't, you can then make fixes and resubmit to github.

Step 3.

Write code to print out thelocationsof each of the variables, in hexadecimal, on separate lines. Compile and then run your program. like this:./tester step3

Note: if you get a weird answer for when you print out the location of thecharvariable, don't worry about it. Just go on.

Step 4.

Inns(), write code to initialize a variable of typeintto the value 37.

Write code to print out the value of that variable in decimal, octal, and hexadecimal, each on its own separate line. You will have to google how to do this in C++. 

Compile and then test your output by running./tester step4

Step 5.

Inarrays(), create a variable that will hold an array of 20floats.

Write a line of code to print out the total size of that variable in decimal. Note that you might findsizeof()useful.

Compile and then test your output by running./tester step5

Step 6.

Indec(), create a variable that is anunsignedinteger, initialized to 0.

Write code to decrement the value, and then print it out.

Add a comment to your code to explain why you do not see -1 in the output. You may have to ask Google for the answer.

Compile and then test your output by running./tester step6

Submit 

In VS Code, click on the Source Control icon on the upper left and type in a commit message, then click the checkmark icon to submit your code. Go through the various pop-up boxes to commit your changes to your repo. You should check to see if the automated tests pass. If they do not, then make fixes to your code and commit them and sync them to github, then watch to see if the automated tests pass.

Grading Rubric

This lab is worth 12 pts: 

  • 2 points for each of steps 3, 4, 5, 6 passing the automated tests.

  • 2 points for clean, hospitable code.

  • 2 points for following directions correctly.

The project is due at midnight on Monday. You will receive a 10% per day penalty for lateness.

Examples of how students lost points in the past:

  • -1: Need a comment explaining why the output isn't -1 (Step 6). Output is incorrect for Step 6 because a post-decrement was used.

  • -1: unsigned int needs to be const unsigned int (Step 2)

  • -1: Code for Step 2 doesn't compile; your string needs to be quoted

  • -1: Hexadecimal output is wrong for Step 4.

  • -1: Step 2 doesn't compile. Chars need to be single-quoted

发表评论

电子邮件地址不会被公开。 必填项已用*标注