Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- PROBLEM #1
- Using the C Program Structure discussed earlier, discuss and understand what is happening on each line of the
- following Hello World program source code. We cover printf and scanf in greater detail in Canvas Module 3.
- #include <stdio.h>
- int main(void)
- {
- printf(βHello World!!\nβ);
- return 0;
- )
- PROBLEM #2 Using a Free online Compiler
- https://www.programiz.com/c-programming/online-compiler/
- OR
- https://www.tutorialspoint.com/compile_c_online.php
- Copy the source code below exactly into the IDE of your choice (Or the links provided above). Attempt to compile it.
- Examine the compiler errors and fix the syntax errors one at a time starting with the first
- error on top. Ask PASS leader about the scanf() and printf() modifiers if you need help.
- Broken Program Source Code:
- /**************************************************
- * Top comment code is not required 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 (Note Mac users can use vlabs for Word or use another text editor)
- This lab will demonstrate how easy it is to introduce compiler errors into your
- source code when moving your code between applications and editors.
- Copy the code from problem #2 into the Word editor. Now use the ctrl + A key to
- select the code form inside Word and then ctrl + c and ctrl + v to copy and place it
- into a new wordpad document. Observe the format. Did it change slightly? Now
- copy it into a new notepad editor. Did it change?
- If you copy the source from an editor and the text has shifted or wrapped to new
- lines, the new source code file will give you compiler errors. Copy the shifted
- source code from notepad into the repl.it coding window and try to compile it.
- The original program syntax was okay but moving it now caused errors to be
- introduced. The take away here is to always verify your code when you move it
- with a compile in the new location.
- The issue is because rich text and ASCII text are not identical, and some word
- processors add their own markup rules to the document which has non-printable
- characters including new line characters.
- PROBLEM #4 Commenting your source code using the standards in Module 2
- Using the example source code from problem 1, add program comments and also
- add inline comments to identify the various items that correspond to the C
- structure chart labeling the 5 main areas of source code.
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement