How to flip boolean variable from true to false in C++

1 Answer

0 votes
#include <iostream>

using namespace std;

int main()
{
	bool b;

	b = true;

	if (b)
		cout << b << endl;

	b = !b;
	cout << b << endl;

	b = !b;
	cout << b << endl;

	return 0;
}


/*
run:

1
0
1

*/

 



answered Dec 2, 2016 by avibootz

Related questions

1 answer 258 views
1 answer 287 views
2 answers 287 views
1 answer 252 views
1 answer 226 views
1 answer 183 views
1 answer 276 views
...