Advertisement
QuinnSpearman

CS1 Module 10

Nov 12th, 2019
240
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.17 KB | None | 0 0
  1. PROBLEM 1
  2.  
  3. #include <stdio.h>
  4. //Your function prototype goes here
  5. int main(void)
  6. {
  7. //local declarations
  8. //declare an FLA array of integers
  9.  
  10. for(; ; )
  11. {
  12. //add the number into the array
  13. }
  14. for(; ;)
  15. {
  16. printf("Element %d is %d\n", ?, ary[?]);
  17. }
  18. return 0;
  19. }//end main
  20. //Your new function would go here
  21.  
  22.  
  23. PROBLEM 2
  24.  
  25. #include <stdio.h>
  26. //Your function prototype goes here
  27. int main(void)
  28. {
  29. //local declarations
  30. int ary[10];
  31. for(int i = 0; i < 10; i++)
  32. {
  33. ary[i] = i + 1;
  34. }
  35. for(int i = 0; i < 10; i++)
  36. {
  37. printf("Element %d is %d\n", i, ary[i]);
  38. }
  39. //call your function to reverse the array
  40. for(;;)
  41. {
  42. printf("Element %d is %d\n", //finish);
  43. }
  44. return 0;
  45. }//end main
  46. //Your new function would go here
  47. void reverseArray()
  48. {
  49. //local declarations
  50. //declare temp holding variable
  51.  
  52. //Use two counters and make sure to start in the correct
  53. right index
  54. for(;;)
  55. {
  56. //save one item in temp
  57. //move one old item over the other
  58. //move temp to the old item destroying
  59. }
  60. return;
  61. }//end function
  62.  
  63.  
  64. PROBLEM 3
  65.  
  66. #include <stdio.h>
  67. //Your function prototypes
  68. int main(void)
  69. {
  70. //local declarations
  71. //declare your array
  72.  
  73. //local statements
  74. //loop to get values remember to use the ampersand for
  75. storage
  76. for(;;)
  77. {
  78. printf("Enter in 10 numbers one at a time: ");
  79. }
  80. for(;;)
  81. {
  82. printf("You entered: %d\n", );
  83. }
  84. return 0;
  85. }//end main
  86. //Function definition goes here
  87.  
  88.  
  89. PROBLEM 4
  90.  
  91. #include <stdio.h>
  92. //Your function prototypes
  93. int main(void)
  94. {
  95. //local declarations
  96. int ary[10];
  97. //local statements
  98. for(int i = 0; i < 10; i++)
  99. {
  100. printf("Enter in 10 numbers one at a time: ");
  101. scanf("%d", &ary[i]);
  102. }
  103. /*for(int i = 0; i < 10; i++)
  104. {
  105. printf("You entered: %d\n", ary[i]);
  106. }
  107. */
  108. if(isbnTest(ary))
  109. printf("The ISBN is valid\n");
  110. else
  111. printf("The ISBN is invalid\n");
  112.  
  113. return 0;
  114. }//end main
  115. //Function definition goes here
  116. int isbnTest()
  117. {
  118. //Local declarations for weighted sums
  119. int sum = 0;
  120. int value = 0;
  121. for(use two counters here)
  122. {
  123. value = ? * ?;
  124. sum+= value;
  125. }
  126. printf("The sum is %d\n", sum);
  127. return //determine if it is odd or even using modulus
  128. }//end fuction
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement