What will be the output of the following C code if it is executed on 2nd January, 2017 (system date)? [code]#include<stdio.h> #include<time.h> i

Minh Phượng

New member
What will be the output of the following C code if it is executed on 2nd January, 2017 (system date)?
Code:
#include<stdio.h>
#include<time.h>
int main()
{
    struct tm *local, *gm;
    time_t t;
    t=time(NULL);	
    local=localtime(&t);
    printf("%d",local->tm_yday);
    return 0;
}
A. 0
B. 1
C. 2
D. Error
 
Answer: b
Explanation: The output of the code shown above is 1. In the question, it is given that the current date is 2nd January, 2017. (1st Jan – 0, 2nd Jan – 1, 3rd Jan – 2)
 

Tìm kiếm

Back
Top