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 355 views
1 answer 376 views
2 answers 404 views
1 answer 345 views
1 answer 312 views
1 answer 275 views
1 answer 368 views
...