7.2.. Napisati program za odredjivanje y po formuli:

Listing programa:

// 07212507
#include <iostream>
using namespace std;

int main(){
	int a,y;
	
	cout << "Broj: ";
	cin >> a;
	
	if(a >= 0)       // a >= 0 ?
		y = 1;       // da, izracunaj y = 1
	else             // inace
		y = -1;      // izracunaj y = -1

	cout << "Y= " << y << endl;  // ispis
	return 0; 
}

II varijanta
// 07212507
#include <iostream>
using namespace std;

int main(){
	int a,y;
	
    cout << "Broj :";
	cin >> a;
	
	if(a >= 0){
		y=1;
		cout << "Y= " << y << endl;
		}
	else{
		y=(-1);
		cout << "Y= " << y << endl;
	}
	return 0; 
}

Ispis na ekranu:

Index