Display the time of the system and display the right time
of the other country



Display the time of the system and display the right time of the other country..

Answer / ln007

Program to read the current date and time
#include<time.h>
main()
{
struct tm *k;
unsigned long int t;
int h,m,s;
int dd,mm,yy;
t = time(0);
k = localtime(&t);
h = k->tm_hour;
m = k->tm_min;
s = k->tm_sec;
dd = k->tm_mday;
mm = k->tm_mon+1;
yy = k->tm_year+1900;
printf("Time : %d : %d : %d\n",h,m,s);
printf("Date : %d : %d : %d\n",dd,mm,yy);
}

Is This Answer Correct ?    0 Yes 1 No

Post New Answer

More C Code Interview Questions

What are segment and offset addresses?

2 Answers   Infosys,


main() { if (!(1&&0)) { printf("OK I am done."); } else { printf("OK I am gone."); } } a. OK I am done b. OK I am gone c. compile error d. none of the above

3 Answers   HCL,


C statement to copy a string without using loop and library function..

2 Answers   Persistent, TCS,


&#8206;#define good bad main() { int good=1; int bad=0; printf ("good is:%d",good); }

2 Answers  


can you use proc sql to manpulate a data set or would u prefer to use proc report ? if so why ? make up an example and explain in detail

1 Answers   TCS,


main() { int a[10]; printf("%d",*a+1-*a+3); }

1 Answers  


How to palindrom string in c language?

7 Answers   Google,


program to find the roots of a quadratic equation

14 Answers   College School Exams Tests, Engineering, HP, IIIT, Infosys, Rajiv Gandhi University of Knowledge Technologies RGUKT, SSC,


Is the following code legal? struct a { int x; struct a b; }

1 Answers  


what is oop?

3 Answers  


print numbers till we want without using loops or condition statements like specifically(for,do while, while swiches, if etc)!

11 Answers   Wipro,


main() { int c = 5; printf("%d", main||c); } a. 1 b. 5 c. 0 d. none of the above

2 Answers   HCL,


Categories