7.3.. Napisati program za izračunavanje y na osnovu vrijednosti k:

Listing programa:

//07311016
#include <iostream>         
using namespace std;
int main()
{
    	int y;
    	int k;
	cout<<"Koeficijent (1 7)"<<endl;
    	cin>>k;
    	switch (k)
    	{
    		case 1:
        		y = k + 2;
        		cout<<k<<endl;
       		cout<<y;
        		break;
    		case 2:
        		y = k - 2;
        		cout<<k<<endl;
        		cout<<y;
        		break;
    		case 3:
       			y=k*2;
        		cout<<k<<endl;
        		cout<<y;
        		break;
    		case 4:
        		y = k + 2;
        		cout<<k<<endl;
        		cout<<y;
        		break;
    		case 6:
        		y = k - 2;
        		cout<<k<<endl;
        		cout<<y;
        		break;
    		case 5:
         		y=k*2;
        		cout<<k<<endl;
        		cout<<y;
        		break;
    		case 7:
         		y=k*2;
        		cout<<k<<endl;
        		cout<<y;
        		break;
    default:
        cout << "Greska" << endl;
    }
    return 0;
}

Ispis na ekranu:

Index