Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- ////////////////////////////////////////////////////////////////////////////////
- //
- // File : cmpsc311-s17-assign2.c
- // Description : This is the main code file for the CMPSC311 assignment 2.
- // see class assignment for details on what needs to be added.
- //
- // Author : Shubham Goyal
- // Created : 1/22/2017
- //
- #include <math.h>
- #define NUMBER_ENTRIES 20
- ////////////////////////////////////////////////////////////////////////////////
- //
- // Function : main
- // Description : This is the main function for the cmpsc311-s17-assign2 program.
- //
- // Inputs : none
- // Outputs : 0 if successful, -1 otherwise
- void showFloats(float floatArray[], int size ) {
- for(int i=0; i<size; i++) {
- printf("%f", floatArray[i]);
- }
- }
- void showIntegers(int integerArray[], int size) {
- for(int i=0; i<size; i++) {
- printf("%d", integerArray[i]);
- }
- }
- int main( void ) {
- // Local variables
- int integerArray[NUMBER_ENTRIES], i;
- // Read the integer values
- for ( i=0; i<NUMBER_ENTRIES; i++ ) {
- scanf( "%d", &integerArray[i] );
- }
- //Local Variables
- float floatArray[NUMBER_ENTRIES], f;
- // Read the float values --- !!! STILL NEEDS CORRECTION !!!
- for ( f=0; f<NUMBER_ENTRIES; f++ ) {
- scanf( "%f", &floatArray[f] );
- if (f%2 == 0) {
- floatArray[f] = cos(*floatArray[f]);
- }
- else {
- floatArray[f] = sin(*floatArray[f]);
- }
- }
- showFloats(floatArray, NUMBER_ENTRIES);
- // Return successfully
- return( 0 );
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement