I've been given two sets of C code and I've been asked to use this code:
#include <stdio.h>
void main() {
  int n, c=0;
  scanf("%d", &n);
  while(n != 1) {
    c++;
    if(n%2 == 0)
      n = n/2;
    else
      n = 3*n + 1;
  }
  printf("n = %d\n", n);
  printf("iterations = %d\n", c);
}
Then I have to use this code to add a time stamp to the program above after the input statement and before the end of the program. I have to use this to calculate the number of clock cycles and seconds it takes for the program to execute.
#include <stdio.h>
#include <time.h>
void sleep2(int wait) {
  clock_t goal; // clock_t defined in <time.h>
  goal = wait * CLOCKS_PER_SEC + clock();
  while( goal > clock() )
    ;
}
main() {
  int delay;
  printf("Enter an integer ...\n");
  scanf("%d", &delay);
  printf("To be delayed for %d seconds ...\n", delay);
  sleep2(delay);
  printf("expired\n");
}
I feel like this should be simple, but I'm not sure how to use the code to put in a time stamp. Could someone help me with the code or just get me started?
Thanks!
 
     
     
     
    