Advertisement
M4ritimeSeeker

PASS Week 1/20

Jan 17th, 2021
91
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.68 KB | None | 0 0
  1. PROBLEM #1
  2.  
  3. Using the C Program Structure discussed earlier, discuss and understand what is happening on each line of the
  4. following Hello World program source code. We cover printf and scanf in greater detail in Canvas Module 3.
  5.  
  6.  
  7. #include <stdio.h>
  8.  
  9. int main(void)
  10. {
  11.  
  12. printf(β€œHello World!!\n”);
  13. return 0;
  14.  
  15. )
  16.  
  17.  
  18.  
  19.  
  20.  
  21.  
  22.  
  23.  
  24.  
  25.  
  26.  
  27.  
  28. PROBLEM #2 Using a Free online Compiler
  29.  
  30. https://www.programiz.com/c-programming/online-compiler/
  31.  
  32. OR
  33.  
  34. https://www.tutorialspoint.com/compile_c_online.php
  35.  
  36.  
  37. Copy the source code below exactly into the IDE of your choice (Or the links provided above). Attempt to compile it.
  38. Examine the compiler errors and fix the syntax errors one at a time starting with the first
  39. error on top. Ask PASS leader about the scanf() and printf() modifiers if you need help.
  40.  
  41. Broken Program Source Code:
  42.  
  43.  
  44. /**************************************************
  45. * Top comment code is not required for this example.
  46. * You would put your
  47. * N number here too.
  48. **************************************************
  49. #include <stdioh>
  50.  
  51. int main(int)
  52. {
  53.  
  54. int age_In = 0:
  55. print("Enter in your age please.\n");
  56. scanf("%d", age_in);
  57. printf("You told me your age is: %f\n");
  58. return;
  59.  
  60. }
  61.  
  62.  
  63.  
  64.  
  65.  
  66.  
  67.  
  68.  
  69.  
  70.  
  71.  
  72.  
  73.  
  74.  
  75. PROBLEM #3 (Note Mac users can use vlabs for Word or use another text editor)
  76.  
  77. This lab will demonstrate how easy it is to introduce compiler errors into your
  78. source code when moving your code between applications and editors.
  79.  
  80. Copy the code from problem #2 into the Word editor. Now use the ctrl + A key to
  81. select the code form inside Word and then ctrl + c and ctrl + v to copy and place it
  82. into a new wordpad document. Observe the format. Did it change slightly? Now
  83. copy it into a new notepad editor. Did it change?
  84.  
  85. If you copy the source from an editor and the text has shifted or wrapped to new
  86. lines, the new source code file will give you compiler errors. Copy the shifted
  87. source code from notepad into the repl.it coding window and try to compile it.
  88. The original program syntax was okay but moving it now caused errors to be
  89. introduced. The take away here is to always verify your code when you move it
  90. with a compile in the new location.
  91.  
  92. The issue is because rich text and ASCII text are not identical, and some word
  93. processors add their own markup rules to the document which has non-printable
  94. characters including new line characters.
  95.  
  96.  
  97.  
  98.  
  99.  
  100.  
  101.  
  102.  
  103.  
  104.  
  105.  
  106.  
  107.  
  108.  
  109.  
  110.  
  111. PROBLEM #4 Commenting your source code using the standards in Module 2
  112.  
  113. Using the example source code from problem 1, add program comments and also
  114. add inline comments to identify the various items that correspond to the C
  115. structure chart labeling the 5 main areas of source code.
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement