All pastes #967461 Raw Edit

Something

public c v1 · immutable
·published 2008-04-02 13:13 UTC
rendered paste body
/***************************************************************************** COSC1283/1284 Programming Techniques Assignment #1* Author:            <insert name here>* Student Number:    <insert student number here>* Yallara Username:  <insert username here>* Start up code provided by Xiaodong Li - xiaodong@cs.rmit.edu.au*                    and by Geoff Warburton - geoffw@cs.rmit.edu.au****************************************************************************/#include "assign1.h"/* This source file contains important functions to be developed and * used by various menu options, as indicated. Note that every * function has as its first parameter the optionsStats array, which * will be appropriately updated for later reporting of menu option 6. * You may ignore this parameter and its relevance to each function * until you develop the sessionSummary() function. *//* Function calculateAge() calculates calculate the number of days  * between two dates to allow the user to know how old they were at  * a particular date. You will need to prompt the user for two dates  * (strings) of 10 characters each in dd/mm/yyyy format. You will  * need to output the number of days between these two dates.  * This functoin will be used in menu option 1. */void calculateAge(int * optionStats, char * dateFrom, char * dateTo){     time_t dateTime1, dateTime2;     struct tm date1,date2, *d1, *d2;     char *pch;     int dates1[3], dates2[3], i=0;          optionStats++;     printf("DOB entered is %s\nTest date enetered is %s\n\n",dateFrom,dateTo);          pch = strtok (dateFrom,"/");     while (pch != NULL)     {        dates1[i] = atoi(pch);        i++;        pch = strtok (NULL, "/");     }          date1.tm_mday = dates1[0];     date1.tm_mon = dates1[1];     date1.tm_year = dates1[2];          d1 = &date1;          dateTime1 = mktime(d1);     printf("DateTime1 %d\n",dateTime1);          i=0;     pch = strtok (dateTo,"/");     while (pch != NULL)     {        dates2[i] = atoi(pch);        i++;        pch = strtok (NULL, "/");     }          date2.tm_mday = dates2[0];     date2.tm_mon = dates2[1];     date2.tm_year = dates2[2];          d2 = &date2;}/* Function insertAString() makes use of three parameters, str, substr,  * and i. The parameters str and substr are char arrays. The parameter i  * is an int. The function will insert the string substr into str  * immediately after index i. Assume that str is large enough to hold  * the added characters. This function will be used in menu option 2. */ void insertAString(int * optionStats, char * str, char * substr, int i){}/* This function converts a Roman numeral into its decimal equivalent.  * The function prompts the user for a Roman numeral, which is entered  * as a character string. The function first converts the Roman numeral  * to decimal and then prints the decimal numeral. The function halts  * when the user enters a string that is not a valid Roman numeral.  * This function will be used in menu option 3. */void convertRomanNumerals(int * optionStats, char * RomanNumeral){}/* Function magicSquare() should be able to generate not only a 3 x 3  * magic square, but also a 5 x 5 magic square. See detailed description  * in the assignment specs. This function will be used in menu option 4. */void magicSquare(int * optionStats, int size){}/* Function pascalTriangle() creates 2-dimensional matrix representing  * the Pascal triangle. In a Pascal triangle, each element is the sum of  * the element directly above it and the element to the left of the element  * directly above it (if any).  Your function should be able to create the  * triangle of any size (assuming that the maximal size is 10 for this option). * The completed triangle should be also displayed as in a center-aligned  * format (see requirement#6 for an example). This function will be used in  * menu option 5. */void pascalTriangle(int * optionStats, int size){}/* Function sessionSummary() reports some program usage information to the * user. This function will be used in menu option 6. */void sessionSummary(int * optionStats){}