redhat
Mad and Furious
I am new to programming in C++, although I have done Java
Recently, while writing a C++ program, I used two loops as follows:
I am using the Turbo C V3 compiler, since my college requires me to do so....
Now my problem is that, the compiler gave me an error in the 2nd loop saying that variable i is already defined. Upon changing the variable name in the 2nd loop, my program ran well. I suppose the scope of variable "i" should have ended before the 2nd loop, why did it give me such an error?
Recently, while writing a C++ program, I used two loops as follows:
Code:
for(int i=0, i<=n; i=i+1)
{
//statements
}
for(int i=0; i<=m; i=i+1)
{
/statements
}
// where n and m are predefined variables
I am using the Turbo C V3 compiler, since my college requires me to do so....
Now my problem is that, the compiler gave me an error in the 2nd loop saying that variable i is already defined. Upon changing the variable name in the 2nd loop, my program ran well. I suppose the scope of variable "i" should have ended before the 2nd loop, why did it give me such an error?