1. 1-masala. A va b ikkita haqiqy sonlar berilgan. Ularning yig’indisi, ayirmasi va ko’paytmasini hisoblang. Yechish. A va b sonlar yig’indisini S, ayirmasini D,


Download 116 Kb.
Sana05.09.2023
Hajmi116 Kb.
#1672825
Bog'liq
1masala BuilderC


1.1-masala. A va B ikkita haqiqy sonlar berilgan. Ularning yig’indisi, ayirmasi va ko’paytmasini hisoblang. Yechish. A va b sonlar yig’indisini S, ayirmasini D, ko’paytmasini K bilan belgilasak, S=a+b, d=a-b, k=a*b formulalar o’rinli bo’ladi.
v oid __fastcall TForm1::Button1Click(TObject *Sender)
{
float a,b,s,p;
a=StrToFloat(Edit1->Text);
b=StrToFloat(Edit2->Text);
s=a+b;
p=a*b;
Edit3->Text=FloatToStr(s);
Edit4->Text=FloatToStr(p);
}
1.2-masala. Birinchi hadi B, maxraji Q va hadlari soni N ga teng geometrik progressiyaning hadlarining yig’indisini hisoblang.

void __fastcall TForm1::Button1Click(TObject *Sender)


{
float B,q,n,S;
B=StrToFloat(Edit1->Text);
q=StrToFloat(Edit2->Text);
n=StrToFloat(Edit3->Text);
S=(B*(1-exp(N*ln(q))))/(1-q);
Edit4->Text=FloatToStr(S);
}
Misol 1: Berilgan a sonini juft yoki toqligini aniqlovchi dastur tuzilsin.
v oid __fastcall TForm1::Button1Click(TObject *Sender)
{
int a;
a=StrToFloat(Edit1->Text);
if (a%2==0) Label1->Caption=("bu son juft!");
else Label1->Caption=("bu son toq!");
}
NATIJA:
Misol 2: 2 ta sondan kattasini topuvchi dastur tuzilsin.
v oid __fastcall TForm1::Button1Click(TObject *Sender)
{
int a,b,c;
a=StrToFloat(Edit1->Text);
b=StrToFloat(Edit2->Text);
c=(a>b)?a:b;
Edit3->Text=FloatToStr(c);
}
Misol: Kiritilgan songa mos ravishda hafta kunini chiqaruvchi programma tuzilsin
.
void __fastcall TForm1::Button1Click(TObject *Sender)
{
int n;
n=StrToFloat(Edit1->Text);
switch (n)
{
case 1: Label3->Caption=("Dushanba"); break;
case 2: Label3->Caption=("Seshanba"); break;
case 3: Label3->Caption=("Chorshanba"); break;
case 4: Label3->Caption=("Payshanba"); break;
case 5: Label3->Caption=("Juma"); break;
case 6: Label3->Caption=("Shanba"); break;
case 7: Label3->Caption=("Yakshanba"); break;
default: Label3->Caption=("Bunday hafta kuni yo'q");
}
NATIJA:

2.8-masala. Ax+B=0 tenglamani yeching.
void __fastcall TForm1::Button1Click(TObject *Sender)
{
Float a,b,x;
a=StrToFloat(Edit1 ->Text);
b=StrToFloat(Edit2 ->Text);
if a=0 then
{if b!=0 then showmessage(‘Bu tenglamaning yechimi yo`q!’)
else
Edit3 ->Text=’Bu tenglamaning yechimlari cheksiz ko`p!’
else { x:=-b/a; Edit3 ->Text:=FloatTostr(x);
}}
}
2.9-masala. Bir tomoni va unga yopishgan ikkita burchagi berilgan uchburchakning uchinchi burchagi va qolgan ikki tomonini aniqlang.
void __fastcall TForm1::Button1Click(TObject *Sender)
{
Float a,ab,bb,b,c,cb;
a=StrToFloat(Edit1 ->Text);
ab=StrToFloat(Edit2 ->Text);
bb=StrToFloat(Edit3 ->Text);
cb=pi-ab*pi/180-bb*pi/180;
b=a*sin(bb)/sin(ab);
c=a*sin(cb)/sin(ab);
Edit4 ->Text=FloatToStr(cb);
Edit5 ->Text=FloatToStr(b);
Edit6 ->Text:=FloatToStr(c);
}
Download 116 Kb.

Do'stlaringiz bilan baham:




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