Advertisement
Guest User

Untitled

a guest
Jan 22nd, 2017
116
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.52 KB | None | 0 0
  1. ////////////////////////////////////////////////////////////////////////////////
  2. //
  3. // File : cmpsc311-s17-assign2.c
  4. // Description : This is the main code file for the CMPSC311 assignment 2.
  5. // see class assignment for details on what needs to be added.
  6. //
  7. // Author : Shubham Goyal
  8. // Created : 1/22/2017
  9. //
  10.  
  11. #include <math.h>
  12.  
  13. #define NUMBER_ENTRIES 20
  14.  
  15. ////////////////////////////////////////////////////////////////////////////////
  16. //
  17. // Function : main
  18. // Description : This is the main function for the cmpsc311-s17-assign2 program.
  19. //
  20. // Inputs : none
  21. // Outputs : 0 if successful, -1 otherwise
  22.  
  23. void showFloats(float floatArray[], int size ) {
  24. for(int i=0; i<size; i++) {
  25. printf("%f", floatArray[i]);
  26. }
  27. }
  28.  
  29. void showIntegers(int integerArray[], int size) {
  30. for(int i=0; i<size; i++) {
  31. printf("%d", integerArray[i]);
  32. }
  33. }
  34.  
  35. int main( void ) {
  36.  
  37. // Local variables
  38. int integerArray[NUMBER_ENTRIES], i;
  39.  
  40. // Read the integer values
  41. for ( i=0; i<NUMBER_ENTRIES; i++ ) {
  42. scanf( "%d", &integerArray[i] );
  43. }
  44.  
  45. //Local Variables
  46. float floatArray[NUMBER_ENTRIES], f;
  47.  
  48. // Read the float values --- !!! STILL NEEDS CORRECTION !!!
  49. for ( f=0; f<NUMBER_ENTRIES; f++ ) {
  50. scanf( "%f", &floatArray[f] );
  51.  
  52. if (f%2 == 0) {
  53. floatArray[f] = cos(*floatArray[f]);
  54. }
  55.  
  56. else {
  57. floatArray[f] = sin(*floatArray[f]);
  58. }
  59. }
  60. showFloats(floatArray, NUMBER_ENTRIES);
  61.  
  62. // Return successfully
  63. return( 0 );
  64. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement