Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <conio.h>
- #include <windows.h>
- using namespace std;
- int main()
- {
- for (;;)
- {
- char wybor; int a,b,licz=0,wynik=1;
- cout <<"Program do podnoszenia licz do potegi na 3 sposoby"<<endl;
- cout <<"-------------------------------------------------"<<endl;
- cout <<"Podaj liczbe ktora ma byc opdniesiona do potegi: ";
- cin >>a;
- cout <<"I do jakiej potegi podnniesc: ";
- cin >> b;
- system("cls");
- cout <<"-------------------------------------------------"<<endl;
- cout <<" MENU"<<endl;
- cout <<"-------------------------------------------------"<<endl;
- cout <<"1. do...while"<<endl;
- cout <<"2. while"<<endl;
- cout <<"3. for"<<endl;
- cout <<"4. wyjdz z programu"<<endl;
- cout <<"Wybieram: ";
- wybor=getch();
- system("cls");
- switch(wybor)
- {
- case '1':
- {
- do
- {
- wynik=wynik*a;
- licz++;
- }
- while (licz<b);
- cout <<"wymnik to: "<< wynik;
- getch();
- system("cls");
- break;
- }
- case '2':
- {
- while (licz<b)
- {
- wynik=wynik*a;
- licz++;
- }
- cout <<"Wynik to: "<<wynik;
- getch();
- system("cls");
- break;
- }
- case '3':
- {
- for (;licz<b;licz++)
- {
- wynik=wynik*a;
- }
- cout <<"Wynik to: "<< wynik;
- getch();
- system("cls");
- break;
- }
- case '4':
- {
- return 0;
- break;
- }
- default:
- {
- cout <<"Nie ma takiej opcji w menu";
- getch();
- system("cls");
- break;
- }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement