Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- PROBLEM #1
- Using the C Program Structure discussed earlier, MATCH EACH LINE OF THE HELLO WORLD PROGRAM WITH
- THE CORRECT SECTION. Some of the sections WON'T match up to a line of code, and others may match MULTIPLE LINES.
- We cover printf and scanf in greater detail in Canvas Module 3.
- SECTIONS OF C STRUCTURE:
- 1) Local statements/declarations
- 2) Preprocessor directives
- 3) Global declarations
- 4) Other functions
- 5) Main function
- PROGRAM:
- #include <stdio.h>
- int main(void)
- {
- printf(“Hello World!!\n”);
- return 0;
- }
- PROBLEM #2 Error checking and correcting activity
- Copy the source code below exactly into the IDE of your choice (Replit preferred). Attempt to compile it.
- Examine the errors and fix them one at a time starting with the first error on top.
- Ask me about the scanf() and printf() modifiers if you need help.
- Broken Program Source Code:
- /**************************************************
- * Top comment code is not filled for this example.
- * You would put your
- * N number here too.
- **************************************************
- #include <stdioh>
- int main(int)
- {
- int age_In = 0:
- print("Enter in your age please.\n");
- scanf("%d", age_in);
- printf("You told me your age is: %f\n");
- return;
- }
- PROBLEM #3 Commenting your source code properly
- Using the fixed code from problem #2, add comments to the program.
- Use the comments to label each section of code and describe what they do.
- Also fill in the top comment with the proper format (Hint: Check the "Comments" Module on Canvas for the format).
- Refer to Zybook section 2.8 for help as well.
- PROBLEM #4: Moving Code around text editors
- For this problem, completed sample code has been provided below.
- The goal of this problem is to copy-paste this program around some text editors until we get it onto the Osprey Server.
- Take the following code and copy it. Then do the following steps:
- -Paste it in replit.
- -Copy it again from replit, and then paste it in a blank word document.
- -Copy it from the word document, and paste it back into replit.
- -Check if any errors have occurred in the program. If none, go to next step.
- -Download the program file from Replit.
- -Login to the Osprey Server
- -Transfer the Program file from your home computer to the Osprey Server
- -Compile and run the program on Osprey and make sure it works.
- #include <stdio.h>
- #define DOLLARS 9999
- #define CENTS 99
- int main()
- {
- const short int VALUE1 = -32768;
- unsigned int value2 = 4294967295;
- float moreMoney = 199.955;
- printf("The value of Dollars and Cents is: %d.%d\n", DOLLARS, CENTS);
- printf("The value of moreMoney is : %lf\n", moreMoney);
- printf("The value of the short integer is: %d\n", VALUE1);
- printf("The value of the short unsigned integer is: %d\n", value2);
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment