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

Finding a number multiplication of 8 with out using arithmetic operator

8 Answers   Eyeball, NetApp,


What is the output for the following program main() { int arr2D[3][3]; printf("%d\n", ((arr2D==* arr2D)&&(* arr2D == arr2D[0])) ); }

1 Answers  


main() { int i=-1,j=-1,k=0,l=2,m; m=i++&&j++&&k++||l++; printf("%d %d %d %d %d",i,j,k,l,m); }

1 Answers  


Given a spherical surface, write bump-mapping procedure to generate the bumpy surface of an orange

0 Answers  


void main() { static int i=i++, j=j++, k=k++; printf(“i = %d j = %d k = %d”, i, j, k); }

3 Answers  






main() { int i=5; printf("%d",++i++); }

1 Answers  


main() { char *cptr,c; void *vptr,v; c=10; v=0; cptr=&c; vptr=&v; printf("%c%v",c,v); }

1 Answers  


What is full form of PEPSI

0 Answers  


main() { clrscr(); } clrscr();

2 Answers  


main() { 41printf("%p",main); }8

1 Answers  


Write a routine to implement the polymarker function

0 Answers   TCS,


main() { int i; float *pf; pf = (float *)&i; *pf = 100.00; printf("\n %d", i); } a. Runtime error. b. 100 c. Some Integer not 100 d. None of the above

2 Answers   HCL, LG,


Categories