A possible program is
here.
That's how the program looked
before I wrote the implementation
of the class functions.
Addresses: 16892 16893 16894 16895 16896 16897 16898 16899 |------- temp --------| |------ dist ---------| Addresses: 16900 16901 16902 16903 16904 16905 16906 16907 |---------------- date -----------------------| Addresses: 16908 16909 16910 16911 16912 16913 16914 16915 |---------------- miles --------------------|
/* Math 2120, Fall'04, Asst 4, Q.2c */ /* This program prints the number of bytes used by a computer to store the address of int, char, and double. Then it prints the number of bytes used to store values of these types. */ #include <stdio.h> int main() { printf("Size of address of int is %d\n",sizeof(int*)); printf("Size of address of char is %d\n",sizeof(char*)); printf("Size of address of double is %d\n",sizeof(double*)); printf("\nCompare the sizes of the values:\n"); printf("Size of int is %d\n",sizeof(int)); printf("Size of char is %d\n",sizeof(char)); printf("Size of double is %d\n",sizeof(double)); return(0); }Here is the output:
Size of address of int is 4 Size of address of char is 4 Size of address of double is 4 Compare the sizes of the values: Size of int is 4 Size of char is 1 Size of double is 8As we see, every address occupies 4 bytes. We should have expected that these numbers are same, because all the addresses denote the first memory location used by a variable pointed to. All memory locations are numbered by consequtive integers, which can be used to denote location of a variable of any type.
#include <stdio.h> void time(int*, int*); int main() { int min, hour; printf("Enter two numbers :"); scanf("%d %d", &min, &hour); time(&min, &hour); return 0; } void time(int *min, int *hour) { int sec; sec= ((*hour)*60 + *min)*60; printf("The total number of seconds is %d", sec); return; }