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 356 views
1 answer 377 views
2 answers 404 views
1 answer 346 views
1 answer 313 views
1 answer 277 views
1 answer 369 views
...