How to get diffrence between two times in Turbo C


  • How to get diffrence between two times in Turbo C


  • 1 Comment sorted by



  • #include
    #include
    main()
    {
    char str1[9];
    char str2[9];

    long int h1,m1,s1;
    long int h2,m2,s2;

    long int a;
    clrscr();
    printf("Enter 1st time:");
    gets(str1);
    printf("Enter 2nd time:");

    gets(str2);
    h1=(((str1[0]-48)*10)+(str1[1]-48));
    m1=(((str1[3]-48)*10)+(str1[4]-48));

    s1=(((str1[6]-48)*10)+(str1[7]-48));
    a=((h1*3600)+(m1*60)+s1);
    printf("Total Ses in Clock 1:\n %ld",a/60);
    h2=(((str2[0]-48)*10)+(str2[1]-48));

    m2=(((str2[3]-48)*10)+(str2[4]-48));
    s2=(((str2[6]-48)*10)+(str2[7]-48));

    long int b=((h2*3600)+(m2*60)+s2);
    printf("Total Sec in Clock 2:\n %ld",b/60);
    printf("\n\ndifrence in Total minutes b/w Two Clocks:");
    printf("%ld",(a-b)/60);
    printf("\nMinutes in Clock 1 - Clock 2: m=%d",m1-m2);
    getch();
    }

Howdy, Stranger!

It looks like you're new here. If you want to get involved, or you want to Ask a new Question, Please Login or Create a new Account by Clicking below

Login with Facebook

Popular Posts of the Week

Top Posters Weekly

Optimum Creative