What will be the output of the following C code if the name entered is "TOM" and time taken to enter this name is 2 seconds?
#include <stdio.h>
#include <time.h>
int main ()
{
time_t time1,time2;
char get_input [256];
double dif_sec;
time (&time1);
printf ("Please enter the name of your pet: ");
gets (get_input);
time (&time2);
dif_sec = difftime (time2,time1);
printf ("%.2f\n", dif_sec );
return 0;
}
#include <stdio.h>
#include <time.h>
int main ()
{
time_t time1,time2;
char get_input [256];
double dif_sec;
time (&time1);
printf ("Please enter the name of your pet: ");
gets (get_input);
time (&time2);
dif_sec = difftime (time2,time1);
printf ("%.2f\n", dif_sec );
return 0;
}A. Error
B. 2
C. 2.0
D. 2.00
Answer: Option D

Join The Discussion