0

Suppose I have 3 int variable named var1,var2,var3 how do i cin this using forloop and then cout the inputted data

For loop c++

13th Dec 2019, 1:09 AM
Kruuk
1 Answer
+ 1
Well if you already have 3 variables just do std::cin >> var1 >> var2 >> var3; std::cout << var1 << var2 << var3; but if you want a for loop without arrays or anything helpful [UNTESTED] for (int i=0; i < 3; i++){ switch(i){ case 0: std::cin >> var1; break case 1: std::cin >> var 2; break; case 2: std::cin >> var3; break; default: break; } } // Bad and cout the same as above
13th Dec 2019, 5:48 AM
「HAPPY TO HELP」
「HAPPY TO HELP」 - avatar