Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- PROBLEM 1: Interacting with systems software using standard input and the virtual terminal for output.
- Follow the PASS leader as they ask you to follow their lead exploring your computer. Introduction to the File System using Systems Software. (Windows & Mac)
- Windows Users:
- - Interact with the file system using utility software. (cmd)
- - From the root of the filesystem run through various utilities demonstrating how to (cd, dir) both text files and binary files are
- listed in the Windows environment.
- - Discuss the idea of filepath. (c:\Users\NXXXXX\Desktop).
- o The name of the executable program is a binary file.
- o The programs are created from source files.
- Linux/Mac Users:
- - Interact with the file systems using the bash command terminal. (under utilities)
- - Change directory using the cd utility, list the files using the ls utility.
- Quick List of Useful Commands and the Windows or Linux/Mac Equivalent
- WINDOWS ------ LINUX/MAC
- dir ls (Lists the content of the directory you are in)
- cd cd (Change the current directory. EXAMPLE: cd Downloads)
- cls clear (Clears all text from the terminal, making it easier to read)
- md mkdir (Make a new Directory. EXAMPLE: mkdir NewDirectory)
- rmdir rmdir (Remove a Directory. EXAMPLE: rmdir NewDirectory)
- copy NUL touch (Make a new file of any type. EXAMPLE: copy NUL file.txt EXAMPLE2: touch file.txt)
- PROBLEM #2: Matching Activity of C Structure and Commenting
- Using the C Program Structure handout, MATCH EACH LINE OF THE PROGRAM BELOW WITH THE CORRECT COMMENT.
- Some of the comments may match multiple lines.
- We cover printf and scanf in greater detail in Canvas Module 3.
- We cover user defined functions in a far future module
- (i.e. don't worry about the doesNothing function too much, just label to the best of your knowledge)
- COMMENTS:
- //Local statements/declarations
- //Preprocessor directives
- //Global declarations
- //Other functions
- //Main function
- PROGRAM:
- #include <stdio.h>
- #define PI 3.14
- int doesNothing(void);
- int main(void)
- {
- printf(“Hello World!!\n”);
- doesNothing();
- return 0;
- }
- int doesNothing(){
- return 0;
- }
- PROBLEM #3: Error checking and correcting activity
- 3 types of Errors:
- • Syntax errors – wont compile because of incorrect syntax of the language
- • Logical errors – Gets the wrong answers but runs / bad design
- • Run time errors – Program ends unpredictably or unexpectedly / Usually due to accessing memory incorrectly.
- Copy the defective source code below exactly into the IDE of your choice. Attempt to compile it. Examine the compiler errors and fix the syntax errors one at a time starting with the firsterror on top of the errors reported. Ask Justin if you need help with scanf() and printf() modifiers. We learned these functions in Week 2.
- 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 #4: Formatting output using printf() format specifiers.
- Using the incomplete program below, add format specifiers to print out the various variable values and constants
- correctly. The variables that hold money values should be printed out with a precision of .2 and should have a width that fills the following digits: “0000.00”. Sample output is provided below the program as well.
- Use the following link for more information on format specifiers and how to give the output precision:
- https://www.tutorialspoint.com/format-specifiers-in-c
- PROGRAM:
- #include <stdio.h>
- #define DOLLARS 9999
- #define CENTS 99
- int main()
- {
- const short int VALUE1 = -32768;
- unsigned int value2 = 4294967295;
- float moreMoney = 199.955;
- /**** ONLY EDIT THE PRINTF STATEMENTS BELOW ****/
- printf("The value of Dollars and Cents is: $\n", DOLLARS, CENTS);
- printf("The value of moreMoney is : %\n", moreMoney);
- printf("The vlaue of the short integer is: %\n", VALUE1);
- printf("The value of the short unsigned integer is: %\n", value2);
- return 0;
- }
- SAMPLE OUTPUT:
- The value of Dollars and Cents is: $9999.99
- The value of moreMoney is : 199.96
- The vlaue of the short integer is: -32768
- The value of the short ungisned integer is: 4294967295
Add Comment
Please, Sign In to add comment