Main.cc: In function 'int main()': Main.cc:5:16: error: redeclaration of 'int n' int n,sum=0,n,m; ^ Main.cc:5:8: note: 'int n' previously declared here int n,sum=0,n,m; ^ Main.cc:7:8: error: 'i' was not declared in this scope for(i=n;i<=m;i++) ^