Professional Documents
Culture Documents
Структура за избор од две можности
Структура за избор од две можности
int main()
{
bool c;
c = 5>3;
cout << " Dali 5>3? " <<endl<<c<<endl;
system ("pause");
return 0;
}
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;
}
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;
}
#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. Проверува дали дадениот број е едноцифрен
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. Програма која определува дали бројот е парен или непарен
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
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;
}
#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;
}