728x90
반응형
#include <iostream>
using namespace std;

bool Positive(int);

int main(void)
{
	bool pos;
	int num;
	cout << "Input Number: ";
	cin >> num;

	pos = Positive(num);
	if (pos)
	{
		cout << "Positive number" << endl;
	}
	else
		cout << "Negative number" << endl;

	cout << pos << endl;
	int size = sizeof(pos);
	cout << size << endl;

	return 0;
}

bool Positive(int num)
{
	if (num <= 0)
	{
		return false;
	}
	else
		return true;
}
728x90
반응형

'Language > C & C++' 카테고리의 다른 글

[C++]How to create two Class-based object(*, &)  (0) 2022.10.17
[C++] Dynamic Memory Allocation(compare malloc with new)  (0) 2022.10.17
[C++] Related to Namespace  (0) 2022.10.17
[C++] Related to Inline  (0) 2022.10.17
[C++] Related to Reference  (0) 2022.10.17

+ Recent posts