Date & Time Function MCQ Questions
This section focuses on the "Date and Time Function" in C programming. These Multiple Choice Questions (MCQ) should be practiced to improve the C programming skills required for various interviews (campus interview, walk-in interview, company interview), placement, entrance exam and other competitive examinations.
1. ____________ in C are used to interact with system time routine and formatted time outputs are displayed
A. Ceil function
B. Time functions
C. Measure function
D. Hour function
View Answer
Ans : B
Explanation: Time functions in C are used to interact with system time routine and formatted time outputs are displayed
2. Which function used to modify the system date?
A. getdate
B. clock
C. setdate
D. mktime
View Answer
Ans : C
Explanation: setdate() : This function used to modify the system date
3. What is true about strftime function?
A. This function is used to get current system time as structure
B. This function is used to get the difference between two given times
C. This function interprets tm structure as calendar time
D. This function is used to modify the actual time format
View Answer
Ans : D
Explanation: strftime(): This function is used to modify the actual time format
4. The time() function is defined in __________ header file.
A. ctime.h
B. time.h
C. clock.h
D. date.h
View Answer
Ans : B
Explanation: The time() function is defined in time.h (ctime in C++) header file.
5. Which of the following library functions returns the time in UTC (Greenwich mean time) format?
A. localtime()
B. gettime()
C. gmtime()
D. settime()
View Answer
Ans : C
Explanation: The library function gmtime() returns the time in UTC format. To find the current time, we use the function localtime().
6. asctime() structure contents are interpreted by this function as calendar time.
A. Yes
B. No
C. Can be yes or no
D. Can not say
View Answer
Ans : A
Explanation: Yes, asctime() structure contents are interpreted by this function as calendar time. This time is converted into string.
7. Which of the following format specifiers is used to represent the name of the time zone?
A. %A
B. %B
C. %H
D. %Z
View Answer
Ans : D
Explanation: The format specifier %Z is used to specify the name of the time zone. %A- full weekday, %B- full month name, %H-hours(0-23).
8. The purpose of the function ctime() is that ___________
A. it returns a string representing the local time
B. it returns a void string
C. it returns a string representing the time in UTC format
D. it returns a string representing the time stored in a structure
View Answer
Ans : A
Explanation: The library function ctime() returns a string representation of the local time. The function asctime() returns a string representing the time stored in a structure.
9. Which of the following format specifiers is used to specify whether the given time is in AM or PM?
A. %q
B. %p
C. %Q
D. %P
View Answer
Ans : B
Explanation: %p (small letter) is used to specify whether the given time is in AM or PM. %I is used to represent the number of hours in the 12 hour clock format. %X is used to represent the standard time zone.
10. mktime() function interprets tm structure as calendar time.
A. TRUE
B. FALSE
C. Can be true or false
D. Can not say
View Answer
Ans : A
Explanation: True, mktime() function interprets tm structure as calendar time.
Discussion