This group is created to discuss issues related to C++ programming

9 Members
Join Us!

You need to be a member of Virtual Academy of Pakistan to add comments!

Join Virtual Academy of Pakistan

Comments are closed.

conditional operator

Hello, I just have a quick question about the conditional operator. Still a budding programmer here, I was going through this - https://www.scaler.com/topics/c/conditional-operator-in-c/  on conditional operator in c and wanted to understand as I am given x = 1, y = 2, and z = 3.I want to know, why after this statement: {Codey += x-- ? z++ : --z;That y is 5. The values after the statement are x = 0, y = 5, and z = 4. I know the way the conditional operator works is that it is formatted like…

Read more…
0 Replies

How to use for each loop in c++

 {Code}#include <cstdlib> #include <iostream> #include <string>using namespace std;int main() { string str("hello world!"); for (auto &c : str) c = toupper(c); cout << str; return 0; }This c++ code does not compile. Error msg: main.cpp:21: error: a function-definition is not allowed here before ':' token Question: Is there a for each loop in c++ (range for loop?)? what is wrong with the for each loop above? 

Read more…
1 Reply · Reply by SK-MSSE Jul 14, 2022