You are on page 1of 7

Структура за избор од две можности

1. Користење на променлива од типот bool - споредбени изрази


#include <iostream>
#include <string>
using namespace std;

int main()
{
bool c;
c = 5>3;
cout << " Dali 5>3? " <<endl<<c<<endl;
system ("pause");
return 0;
}

2. Програма која определува дали сме малолетни или полнолетни


#include <iostream>
#include <string>
using namespace std;

int main()
{
int godini;
cout << "Kolku godini imate "<<endl;
cin>>godini;
if (godini<=18)
cout << "Maloletni ste "<<endl;
else
cout << "Polnoletni ste " << endl;
system ("pause");
return 0;
}

3. Програма која проверува дали променливата delitel е еднаква на 0


#include <iostream>
#include <string>
using namespace std;

int main()
{
int delitel;
cout << " Vnesi broj" <<endl;
cin>>delitel;
if (delitel==0)
cout << " Ne e mozno delenje so 0 " <<endl;
system ("pause");
return 0;
}

4. Од два цели броја го покажува поголемиот

#include <iostream>
#include <string>
using namespace std;

int main()
{
int a,b;
cout << " Vnesi dva razlicni celi broja" <<endl;
cin>>a>>b;
if (a>b)
cout << " Brojot " <<a<<" e pogolem. " << endl;
else
cout << " Brojot " <<b<<" e pogolem. " << endl;
system ("pause");
return 0;
}
5. Проверува дали дадениот број е едноцифрен

// dali daden broj e ednocifren


#include <iostream>
#include <string>
using namespace std;

int main()
{
int x;
cout << " Vnesi cel broj" <<endl;
cin>>x;
if (0<=x && x<=9)
cout << " Brojot " <<x<<" e ednocifren. " << endl;
else
cout << " Brojot " <<x<<" ne e ednocifren. " << endl;
system ("pause");
return 0;
}
6. Програма која определува дали бројот е парен или непарен

// dali daden broj e paren ili neparen


#include <iostream>
#include <string>
using namespace std;

int main()
{
int broj;
cout << " Dali brojot e paren ili neparen" <<endl;
cout << " Vnesi eden broj" <<endl;
cin>>broj;
if (broj%2==0)
cout << " Brojot e paren. " << endl;
else
cout << " Brojot ne e paren. " << endl;
system ("pause");
return 0;
}
7. Програма која определува дали бројот е делив со 6

// dali daden broj e deliv so 6


#include <iostream>
#include <string>
using namespace std;

int main()
{
int broj;
cout << " Dali brojot e deliv so 6" <<endl;
cout << " Vnesi eden broj" <<endl;
cin>>broj;
if (broj%6==0)
cout << " Brojot e deliv so 6. " << endl;
else
cout << " Brojot ne e deliv so 6. " << endl;
system ("pause");
return 0;
}

8. Програма која определува дали бројот е негативен или позитивен и ја дава неговата
апсолутна вредност

#include <iostream>
#include <string>
using namespace std;

int main()
{
int x;
cout << "vnesi eden broj "<<endl;
cin>>x;
if (x<0)
{
cout << "brojot "<<x<< " e negativen "<<endl;
cout << "Negovata apsolutna vrednost e "<<-x<< endl;
}
else
{
cout << "brojot "<<x<< " ne e negativen "<<endl;
cout << "Negovata apsolutna vrednost e "<<x<< endl;
}

system ("pause");
return 0;
}

9. Програма која проверува дадли два броја се еднакви или кој од нив е поголем

#include <iostream>
#include <string>
using namespace std;

int main()
{
int a,b;
cout << " Vnesi dva razlicni celi broja" <<endl;
cin>>a>>b;
if (a==b)
cout << " Broevite se ednakvi " << endl;
else
if (a>b)
cout << " Brojot " <<a<<" e pogolem. " << endl;
else
cout << " Brojot " <<b<<" e pogolem. " << endl;
system ("pause");
return 0;
}

10. Програма која проверува дали бројот е поголем или помал од 10

#include <iostream>
#include <string>
using namespace std;

int main()
{
int a;
cout << " Vnesi eden cel broj" <<endl;
cin>>a;
if (a>10)
cout << " Brojot " <<a<<" e pogolem od 10 " << endl;
else
cout << " Brojot " <<a<<" e pomal od 10 " << endl;
system ("pause");
return 0;
}

You might also like