What will be the output of the following C code if the current system date is 6/22/2017? [code]#include<stdio.h> #include<stdlib.h> #include<tim

Vy Bùi

New member
What will be the output of the following C code if the current system date is 6/22/2017?
Code:
#include<stdio.h>
#include<stdlib.h>
#include<time.h>
typedef struct tm tm;
int main()
{
    time_t ct;
    time(&ct);
    tm *mt=localtime(&ct);
    printf("%d\n",mt-> tm_year);
}
A. 17
B. 2017
C. error
D. 117
 
Answer: d
Explanation: The output of the code shown above is the number of the current year, counted from the year 1900. Hence, since the current year is 2017, the output will be: 2017-1900 = 117.
 

Tìm kiếm

Back
Top