Use time()
to get current time and difftime()
to compute the difference.
#include <iostream>
#include <ctime>
#include <conio.h>
using namespace std;
int main()
{
int a,b;
cout<<"enter 1";
cin>>a;
time_t atime = time(NULL);
cout<<"enter 2";
cin>>b;
time_t btime = time(NULL);
cout << difftime(btime, atime) << " seconds passed\n";
getch();
return 0;
}