1. Sonlar o’qida A,B,C nuqtalar berilgan. C nuqta a va b nuqtalar orasida joylashgan. Ac va bc kesmalar uzunligining ko’paytmasini toping


Download 23.46 Kb.
Sana05.01.2022
Hajmi23.46 Kb.
#203024
Bog'liq
1 (2)


1.Sonlar o’qida A,B,C nuqtalar berilgan. C nuqta A va B nuqtalar orasida joylashgan. AC va BC kesmalar uzunligining ko’paytmasini toping.
#include
using namespace std;
int main(int argc, char** argv) {

float A,B,C,L,L1,L2;

cout<<"A="; cin>>A;

cout<<"C="; cin>>C;

cout<<"B="; cin>>B;

if (A

{if(C

else


{ cout<<"C ni kiritishda xatolik";}

return 0;

}
2.X kg konfet A so’m turadi. 1 kg va Y kg konfet qancha turishini aniqlovchi dastur tuzing.
#include

#include

using namespace std;

int main ()

{

float x,A,b,Y,y;



cout <<"x="; cin >>x;

cout <<"A="; cin >>A;

cout <<"Y="; cin >>Y;

b=A/x;


cout << "1 kg konfet="<y=Y*b;


cout << "Y kg konfet="< return 0;

}
3.Uchta A,B,C butun sonlar berilgan. Jumlani rostlikka tekshiring: “A, B, C sonlarning hech bo’lmaganda bittasi musbat”.
#include

#include

using namespace std;

int main ()

{

int A,B,C;



cout <<"A="; cin >> A;

cout <<"B="; cin >> B;

cout <<"C="; cin >> C;

if (A>0)

cout <<"A,B,C lardan kamida 1 tasi musbat"; else if (B>0)

cout <<"A,B,C lardan kamida 1 tasi musbat"; else if(C>0) cout <<"A,B,C lardan kamida 1 tasi musbat"; else

cout <<"A,B,C larning birortasi musbat emas";

return 0;

}
4.min{max(a,b),c} ifoda uchun dastur tuzing.
#include

#include

using namespace std;

int main ()

{

float min ,max, a,b,c;



cout <<"a="; cin>>a;

cout <<"b="; cin>>b;

cout <<"c="; cin>>c;

if (a>b) max=a ; else max=b;

if (max>c) min=c; else min=max;

cout <<"min="<

return 0;

}
5.max{min(a,b),c} ifoda uchun dastur tuzing.

#include

#include

using namespace std;

int main ()

{

float min ,max, a,b,c;



cout <<"a="; cin>>a;

cout <<"b="; cin>>b;

cout <<"c="; cin>>c;

if (a>b) min=a ; else min=b;

if (min>c) max=c; else max=min;

cout <<"max="<

return 0;

}
6.A va B butun sonlar berilgan.Agar o’zgaruvchilar o’zaro teng bo’lmasa, A va B bu sonlarning kattasini o’zlashtirsin.Agar teng bo’lsa, 0 ni o’zlashtirsin. A va B ning qiymati ekranga chiqarilsin.


#include

#include

using namespace std;

int main ()

{

float A,B,x;



cout <<"A="; cin >>A;

cout <<"B="; cin >>B;

if (A==B) x=0; else

if (A>B) x=A; else x=B;

cout <<"O'zlashtirilishi lozim bo'lgan qiymat=" <

cout << "A="<

cout <<"B="<

return 0;

}
7.N ta natural son berilgan. Dastlabki n ta toq sondan tashkil topgan massivni hosil qiling va elementlarini chiqaring.


8.max(a,b,c,d) ni topish dasturi tuzilsin.

#include

#include

using namespace std;

int main ()

{


float a,b,c,d,max;

cout <<"a="; cin >>a;

cout <<"b="; cin >>b;

cout <<"c="; cin >>c;

cout <<"d="; cin >>d;

if (a>b && a>c && a>d ) max=a; else if (b>c && b>d) max=b; else if (c>d) max=c; else max=d;

cout <<"max="<

return 0;

}
9.Oyning tartib raqamiga ko’ra joriy oy necha kundan ibotar ekanligini hisoblovchi dastur tuzing.

#include

using namespace std;

int main() {

int n;

cout<<"Oyning tartib raqamini kiriting: ";

cin>>n;

switch (n) {

case 1: cout<<"31"; break;

case 2: cout<<"28"; break;

case 3: cout<<"31"; break;

case 4: cout<<"30"; break;

case 5: cout<<"31"; break;

case 6: cout<<"30"; break;

case 7: cout<<"31"; break;

case 8: cout<<"31"; break;

case 9: cout<<"30"; break;

case 10: cout<<"31"; break;

case 11: cout<<"30"; break;

case 12: cout<<"31"; break;

default: cout<<"Hato kiritildi"; break;

return 0;

}}

10. Funksiya yordamida 3 ta butun sonning yig’indisini hisoblovchi dastur tuzing.

#include

#include

using namespace std;

int main ()

{


int a,b,c,Y;

cout <<"a="; cin >>a;

cout <<"b="; cin >>b;

cout <<"c="; cin >>c;

Y=a+b+c;

cout <<"Y="<

return 0;

}

Download 23.46 Kb.

Do'stlaringiz bilan baham:




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