Guest User

Untitled

a guest
Jan 21st, 2018
72
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 5.09 KB | None | 0 0
  1. /*
  2. program : velandoRpgm2.c
  3. author : Rafael Velando
  4. purpose : Implement calling methods/functions, if, else if, else, while, for, printf,
  5. taking data in double dimension array apart, math methods/functions, ascii values,
  6. updated : 10-12-2011
  7.  
  8. *********************************************************************
  9.  
  10. Course : COP 2270 T-FR 12:50 PM
  11. Professor : Michael Robinson
  12. Due Date : 10/11/11
  13. Certification:
  14. I hereby certify that this work is my own and none of it is the work of any other person.
  15.  
  16. *********************************************************************
  17. */
  18.  
  19. #include <stdio.h>
  20. #include <math.h>
  21. #include <string.h>
  22. #include <stdlib.h>
  23.  
  24. void processAbsoluteValues(int i, int j, double x, double y )
  25. {
  26. printf("Abs. Val of %d is %d\n", i, abs(i));
  27. printf("Abs. Val of %d is %d\n", j, abs(j));
  28. printf("Abs. Val of %.1f is %.1f\n", x, fabs(x));
  29. printf("Abs. Val of %.2f is %.2f\n", y, fabs(y));
  30. }
  31. void processRoundValues(int i, int j, double x, double y )
  32. {
  33. printf("Rounded Val of %d is %d\n", i, round(i));
  34. printf("Rounded Val of %d is %d\n", j, round(j));
  35. printf("Rounded Val of %.1f is %.1f\n", x, round(x));
  36. printf("Rounded Val of %.2f is %.2f\n", y, round(y));
  37. }
  38. void processCeilingValues(int i, int j, double x, double y )
  39. {
  40. printf("Ceiling Val of %d is %d\n", i, ceil(i));
  41. printf("Ceiling Val of %d is %d\n", j, ceil(j));
  42. printf("Ceiling Val of %.1f is %.1f\n", x, ceil(x));
  43. printf("Ceiling Val of %.2f is %.2f\n", y, ceil(y));
  44. }
  45. void processFlooringValues(int i, int j, double x, double y )
  46. {
  47. printf("Floor Val of %d is %d\n", i, floor(i));
  48. printf("Floor Val of %d is %d\n", j, floor(j));
  49. printf("Floor Val of %.1f is %.1f\n", x, floor(x));
  50. printf("Floor Val of %.2f is %.2f\n", y, floor(y));
  51. }
  52. void processTrigFunctionsValues(int i, int j, double x, double y )
  53. {
  54. printf("The Cos of %d is %.2f\n", i, cos((double)i));
  55. printf("The Cos of %d is %.2f\n", j, cos((double)j));
  56. printf("The Cos of %.1f is %.2f\n", x, cos(x));
  57. printf("The Cos of %.2f is %.2f\n", x, cos(y));
  58. printf("The Sin of %d is %.2f\n", i, sin((double)i));
  59. printf("The Sin of %d is %.2f\n", j, sin((double)j));
  60. printf("The Sin of %.1f is %.2f\n", x, sin(x));
  61. printf("The Sin of %.2f is %.2f\n", x, sin(y));
  62. printf("The Tan of %d is %.2f\n", i, tan((double)i));
  63. printf("The Tan of %d is %.2f\n", j, tan((double)j));
  64. printf("The Tan of %.1f is %.2f\n", x, tan(x));
  65. printf("The Tan of %.2f is %.2f\n", x, tan(y));
  66. }
  67. void processExponentialValues(int i, int j, double x, double y )
  68. {
  69. printf("Exp. Val of %d is %.1f\n", i, exp(i));
  70. printf("Exp. Val of %d is %.1f\n", j, exp(j));
  71. printf("Exp. Val of %.1f is %.1f\n", x, exp(x));
  72. printf("Exp. Val of %.2f is %.1f\n", y, exp(y));
  73. }
  74. void processLogValues(int i, int j, double x, double y )
  75. {
  76. printf("Log Val of %d is %.1f\n", i, log(i));
  77. printf("Log Val of %d is %.1f\n", j, log(j));
  78. printf("Log Val of %.1f is %.1f\n", x, log(x));
  79. printf("Log Val of %.2f is %.1f\n", y, log(y));
  80. }
  81. void processPowerValues(int i, int j, double x, double y )
  82. {
  83. printf("%d to the power %d is %.1f\n", i, j, pow((double)i,j));
  84. printf("%.1f to the power %.2f is %.1f\n", x, y, pow(x,y));
  85. }
  86. void processSquareRootsValues(int i, int j, double x, double y )
  87. {
  88. printf("The Square Root of %d is %.1f\n", i, sqrt(i));
  89. printf("The Square Root of %d is %.1f\n", j, sqrt(j));
  90. printf("The Square Root of %.1f is %.1f\n", x, sqrt(x));
  91. printf("The Square Root of %.2f is %.1f\n", y, sqrt(y));
  92. }
  93. void processRandomValues(int i, int j, double x, double y )
  94. {
  95. printf("A Random Value generated from my program is %d\n", rand());
  96. printf("A Random Value generated from my program is %d\n", rand());
  97. printf("A Random Value generated from my program is %d\n", rand());
  98. printf("A Random Value generated from my program is %d\n", rand());
  99. }
  100. void NameBrokenDown(char myName[])
  101. {
  102. int d;
  103. for(d = 0;d < strlen(myName); d++)
  104. {
  105. printf("char [%c] located at position %d is ", name[d], d);
  106. if((myName=='a') || (myName=='A') || (myName=='e') || (myName=='E') || (myName=='i') || (myName=='I') || (myName=='o') || (myName=='O') || (myName=='u') || (myName=='U'))
  107. printf("a vowel\n");
  108. elseif((myName=='$') || (myName=='%'))
  109. printf("not a vowel or a consonant\n");
  110. elseif(myName==' ')
  111. printf("a space\n");
  112. else
  113. printf("a consonant\n");
  114. }
  115. }
  116.  
  117.  
  118. int main()
  119. {
  120.  
  121. int i = 3;
  122. int j = 7;
  123. double x = 54.3;
  124. double y = -1.22;
  125.  
  126. char myName[] = "Rafael $ Victor % Velando";
  127.  
  128. processAbsoluteValues(i, j, x, y );
  129. processRoundValues(i, j, x, y );
  130. processCeilingValues(i, j, x, y );
  131. processFlooringValues(i, j, x, y );
  132. processTrigFunctionsValues(i, j, x, y );
  133. processExponentialValues(i, j, x, y );
  134. processLogValues(i, j, x, y );
  135. processPowerValues(i, j, x, y );
  136. processSquareRootsValues(i, j, x, y );
  137. processRandomValues(i, j, x, y );
  138. NameBrokenDown(myName);
  139.  
  140. return 0;
  141. }
Add Comment
Please, Sign In to add comment