This assignment introduces the fundamental concepts of basic output in C++ by creating a simple program that prints a custom message to the terminal. The tasks include using preprocessor directives, managing namespaces, and structuring a basic C++ program, with an emphasis on familiarizing with CodeGrade for submitting and evaluating assignments. These foundational skills are critical for future programming tasks and lay the groundwork for more complex coding challenges. Completing this assignment builds confidence in writing, compiling, and running simple programs, which are crucial skills in both academic and professional settings.
The assignment involves creating a C++ program that outputs a formatted message to the terminal. The task includes writing a C++ program with the necessary preprocessor directives and a main() function. The output must match a specific format provided in the instructions. This exercise helps in becoming familiar with the process of compiling and running C++ code, as well as submitting work through CodeGrade for automated feedback.
Include the <iostream>
library using preprocessor directives (#include <iostream>
).
Use the std
namespace to simplify the code (using namespace std;
).
Define a main()
function in the program.
Copy, paste, and output each line of the provided output message into the main()
function, ensuring it matches the required format (see below for message).
Compile the program using g++ main.cpp
and run it to verify that the output matches the expected result.
Add a header comment at the beginning of the program (see below for formatting).
Submit the main.cpp
file to CodeGrade, following the provided instructions on the Canvas page.
CS135 Assignment 0 HH HH EEEEEEE LL LL OOOOOO HH HH EE LL LL OO OO HHHHHHH EEEEE LL LL OO OO HH HH EE LL LL OO OO HH HH EEEEEEE LLLLLLL LLLLLLL OOOOOO WW WW OOOOOO RRRRRR LL DDDDDD WW WW OO OO RR RR LL DD DD WW WWW WW OO OO RRRRRR LL DD DD WWWW WWWW OO OO RR RR LL DD DD WW WW OOOOOO RR RR LLLLLLL DDDDDD
For this assignment and every assignment your programs must include the following header comment at the very beginning of the program (with theCAPITAL_LETTER_AREAS
filled out with your own information):
/*| Name: YOUR_NAME NSHE ID: YOUR_NSHE_ID_NUMBER Course Name: YOUR_COURSE_NAME Assignment Name: YOUR_ASSIGNMENT_NUMBER */
To compile and run your program to make sure it is running use the following command: g++ main.cpp
g++
is the name of the compiler, main.cpp
is the file name of the source C++ code for your program. The output of the compiler will be an executable file named a.out
(Mac and Linux) -or- a.exe
(Windows). To run a.out
-or- a.exe
you need to type the following at the command prompt:
./a.out
(Mac and Linux)
-or-
./a.exe
(Windows)
To upload this assignment (and all future assignments) to CodeGrade:
Navigate to the Canvas page for your CS 135 Lecture section, then to the page for the assignment.
At the bottom of the page you will see a button to “Load Lab 0B in a new window”. Click this button and you will be redirected to CodeGrade in a new tab. CodeGrade will display multiple buttons. A few of these buttons are:
Click on Upload Files to upload your main.cpp.
Upload main.cpp to CodeGrade by dragging and dropping it from your machine, or by browsing for the file.
Press Submit and you will be presented with the auto test screen, here tests will run to assess your assignment. These tests will fill in rubric categories automatically. If you fail a test click on the test to figure out what went wrong with the test. You can then go back to your code on your local machine, fix the problem, and resubmit to try and pass the test. Note: Your grade in CodeGrade will be a continuous value between 0 and 10. This is not how many points you got on the assignment but a percentage of how many points you will get (i.e. 7.5 = 75%).
For a video tutorial on how to use CodeGrade see: Using CodeGrade
In general, once you have tested your program on your own computer and are confident it works with the example executions, go through this process. There will usually be more input/output tests in CodeGrade than there are in the PDF. If you fail a test in CodeGrade, fix the error on your own machine locally then reupload it to CodeGrade. You will not be deducted points for resubmitting prior to the deadline.
Program Structure:
Include the necessary preprocessor directives (#include <iostream>
).
Use the std
namespace correctly (using namespace std;
).
Define and implement the main()
function properly.
Output Accuracy:
Ensure the program outputs the specified message exactly as provided in the assignment instructions.
Match the format, including spacing and special characters, to avoid discrepancies.
Header Comment:
Include a detailed header comment at the beginning of your program.
The header must include all required information.
Compilation and Execution:
Compile the program using the g++
compiler to ensure it runs without errors.
Verify that the output matches the expected result when executed.
Submission:
Save the program as main.cpp
and submit it to CodeGrade before the deadline.
Use the feedback provided by CodeGrade to identify and correct any errors, then resubmit if necessary.
Rubric and Grading:
Save your code as main.cpp
. Do not ignore this step or save your file(s) with different names.
Submit your program source code via CodeGrade as a properly named .cpp
file prior to the deadline to receive full credit. Any submissions after the deadline will be subject to the class’ late policy.