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 256 views
1 answer 283 views
2 answers 285 views
1 answer 249 views
1 answer 224 views
1 answer 182 views
1 answer 274 views
...