1-misol: if,for,switch-case qatnashgan ixtiyoriy dastur For ga misol


Download 482.27 Kb.
Sana01.01.2023
Hajmi482.27 Kb.
#1074630
Bog'liq
Ma\'ruza mashg\'uloti


1-misol: if,for,switch-case qatnashgan ixtiyoriy dastur
For ga misol:
#include
using namespace std;
int main(){
int sum = 0;
for (int i = 1; i <=10; i++){
cout << sum << " + " << i << endl;
sum = sum + i;
cout << "\nsum =" << sum << endl;
}
cout << sum << endl;
system("pause");
return 0;
}


if va switchga misol:
#include
using namespace std;
int main(){
int n;
cout << "n="; cin >> n;
switch (n){
case 1: cout <<"Dushanba"; break;
case 2: cout <<"Seshanba"; break;
case 3: cout <<"Chorshanba"; break;
case 4: cout <<"Payshanba"; break;
case 5: cout <<"Juma"; break;
case 6: cout <<"Shanba"; break;
case 7: cout <<"Yakshanba"; break;
}
if (n == 1)
cout << "/09:00-18:00";
else
if (n == 2)
cout << "/09:00-18:00";
else
if (n == 3)
cout << "/09:00-18:00";
else
if (n == 4)
cout << "/09:00-18:00";
else
if (n == 5)
cout << "/09:00-18:00";
else
if (n == 6)
cout << "/09:00-15:00";
else
if (n == 7)
cout << "/Dam olish kun";
else
system("pause");
return 0;
}


Download 482.27 Kb.

Do'stlaringiz bilan baham:




Ma'lumotlar bazasi mualliflik huquqi bilan himoyalangan ©fayllar.org 2024
ma'muriyatiga murojaat qiling