Please Tell me where my code is wrong

I have written this simple code to measure the time duration it takes for a user to input the data for calculation. Please help me and correct this program. I shall stay thankful..


1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
//To calculate time duration it takes to perform an operation of addition

#include <iostream>
#include <conio>
#include <time.h>
int main()
{
int a,b,c;
int start, finish;

clock_t start (clock());   //THIS LINE IS GIVING ME ERROR!!
cout<<"Enter digit";
cin>>a;
cout<<"\nEnter digit";
cin>>b;
c = a+b;
clock_t finish (clock()); //THIS LINE IS ALSO GIVING ME ERROR!!


cout<<"Time to calculate sum is:"<<(finish-start)/1000.0<< "seconds";
cout<<c;
getche();
} 




You can't have two variables with the same name defined in the same scope.
Please ask a question just the once!! :-(

Andy

http://www.cplusplus.com/forum/beginner/69065/
Topic archived. No new replies allowed.