O’zbekiston respublikasi oliy va o’rta-maxsus ta’lim vazirligi samarqand davlat universiteti mexanika-matematika fakulteti amaliy matematika va informatika bo’limi



Yüklə 181,19 Kb.
Pdf görüntüsü
səhifə11/12
tarix11.12.2023
ölçüsü181,19 Kb.
#143754
1   ...   4   5   6   7   8   9   10   11   12
c dasturlash tilida hisoblash kalkulyatori yaratish


if ( f != 0) 
StaticText1->Caption = StaticText1->Caption + "0"; 

Kalkulatorning “1” tugmasiga quyidagi dastur kiritiladi: 


// "1"tugmasiga 
void __fastcall TForm1::Btn1Click(TObject *Sender) 

 if ( f == 0) 

StaticText1->Caption = "1"; 
f = 1; 

else 
StaticText1->Caption = StaticText1->Caption + "1"; 

Kalkulatorning “2” tugmasiga quyidagi dastur kiritiladi: 
// "2"tugmasiga 
void __fastcall TForm1::Btn2Click(TObject *Sender) 

 if ( f == 0) 

StaticText1->Caption = "2"; 
f = 1; 



else 
StaticText1->Caption = StaticText1->Caption + "2"; 

Kalkulatorning “3” tugmasiga quyidagi dastur kiritiladi: 
// "3"tugmasiga 
void __fastcall TForm1::Btn3Click(TObject *Sender) 

if ( f == 0) 

StaticText1->Caption = "3"; 
f = 1; 

else 
StaticText1->Caption = StaticText1->Caption + "3"; 

Kalkulatorning “4” tugmasiga quyidagi dastur kiritiladi: 
// "4" tugmasiga 
void __fastcall TForm1::Btn4Click(TObject *Sender) 

if ( f == 0) 



StaticText1->Caption = "4"; 
f = 1; 

else 
StaticText1->Caption = StaticText1->Caption + "4"; 

Kalkulatorning “5” tugmasiga quyidagi dastur kiritiladi: 
// "5" tugmasiga 
void __fastcall TForm1::Btn5Click(TObject *Sender) 

if ( f == 0) 

StaticText1->Caption = "5"; 
f = 1; 

else 
StaticText1->Caption = StaticText1->Caption + "5"; 

Kalkulatorning “6” tugmasiga quyidagi dastur kiritiladi: 
 
// "6"tugmasiga 


void __fastcall TForm1::Btn6Click(TObject *Sender) 

if ( f == 0) 

StaticText1->Caption = "6"; 
f = 1; 

else 
StaticText1->Caption = StaticText1->Caption + "6"; 

Kalkulatorning “7” tugmasiga quyidagi dastur kiritiladi: 
 
// "7" tugmasiga 
void __fastcall TForm1::Btn7Click(TObject *Sender) 

if ( f == 0) 

StaticText1->Caption = "7"; 
f = 1; 

else 
StaticText1->Caption = StaticText1->Caption + "7"; 

Kalkulatorning “8” tugmasiga quyidagi dastur kiritiladi: 


 
// "8"tugmasiga 
void __fastcall TForm1::Btn8Click(TObject *Sender) 

if ( f == 0) 

StaticText1->Caption = "8"; 
f = 1; 

else 
StaticText1->Caption = StaticText1->Caption + "8"; 

Kalkulatorning “9” tugmasiga quyidagi dastur kiritiladi: 
 
// "9" tugmasiga 
void __fastcall TForm1::Btn9Click(TObject *Sender) 

if ( f == 0) 

StaticText1->Caption = "9"; 
f = 1; 

else 


StaticText1->Caption = StaticText1->Caption + "9"; 

Kalkulatorning “c” tugmasiga quyidagi dastur kiritiladi: 
 
// "c" tugmasiga 
void __fastcall TForm1::BtnCClick(TObject *Sender) 

StaticText1->Caption = "0"; 
accum = 0; 
op = 0; 
f = 0; 

Kalkulatorning “+” tugmasiga quyidagi dastur kiritiladi: 
// "+" tugmasiga 
void __fastcall TForm1::BtnPClick(TObject *Sender) 

 
if ( f != 0) 

DoOp(); 
f = 0; 



op =1; 

Kalkulatorning “-” tugmasiga quyidagi dastur kiritiladi: 
 
// "-" tugmasiga 
void __fastcall TForm1::BtnMClick(TObject *Sender) 

if ( f != 0) 

DoOp(); 
f = 0; 

op = 2; 

Kalkulatorning “*” tugmasiga quyidagi dastur kiritiladi: 
 
// "*" tugmasi 
void __fastcall TForm1::BitBtn1Click(TObject *Sender) 

 if ( f != 0) 

DoOp(); 


f = 0; 

op =3; 

Kalkulatorning “/” tugmasiga quyidagi dastur kiritiladi: 
 
// "/" tugmasi 
void __fastcall TForm1::BitBtn2Click(TObject *Sender) 

 if ( f != 0) 

DoOp(); 
f = 0; 

op =4; 

Kalkulatorning “,” tugmasiga quyidagi dastur kiritiladi: 
 
// "," tugmasiga 
void __fastcall TForm1::BtnkClick(TObject *Sender) 

if ( f == 0) 


{ StaticText1->Caption = "0,"; 
f = 1; } 
else 

if ( StaticText1->Caption.Pos(",") == 0) 
StaticText1->Caption = StaticText1->Caption + ","; 


Kalkulatorning “=” tugmasiga quyidagi dastur kiritiladi: 
 
// "="tugmasiga 
void __fastcall TForm1::BtnEClick(TObject *Sender) 

if ( f != 0) 

DoOp(); 
f = 0; 

op = 0; 

Shundan so’ng Formaning umumiy ko’rinishi quyidagicha bo’ladi: 


 
Dasturning umumiy kodi quyidagicha bo’ladi: 
#include  
#pragma hdrstop 
#include "CalcForm.h" 
#pragma package(smart_init) 
#pragma resource "*.dfm" 
TForm1 *Form1; 
float accum; 
int op; 
int f; 
_fastcall TForm1::TForm1(TComponent* Owner) 
: TForm(Owner) 

f =0; 
op = 0; 
StaticText1->Caption = 0; 

// "0"tugmasiga 


void __fastcall TForm1::Btn0Click(TObject *Sender) 

if ( f != 0) 
StaticText1->Caption = StaticText1->Caption + "0"; 

// "1"tugmasiga 
void __fastcall TForm1::Btn1Click(TObject *Sender) 

 if ( f == 0) 

StaticText1->Caption = "1"; 
f = 1; 

else 
StaticText1->Caption = StaticText1->Caption + "1"; 

// "2"tugmasiga 
void __fastcall TForm1::Btn2Click(TObject *Sender) 

 if ( f == 0) 

StaticText1->Caption = "2"; 
f = 1; 

else 
StaticText1->Caption = StaticText1->Caption + "2"; 

// "3"tugmasiga 


void __fastcall TForm1::Btn3Click(TObject *Sender) 

if ( f == 0) 

StaticText1->Caption = "3"; 
f = 1; 

else 
StaticText1->Caption = StaticText1->Caption + "3"; 

// "4" tugmasiga 
void __fastcall TForm1::Btn4Click(TObject *Sender) 

if ( f == 0) 

StaticText1->Caption = "4"; 
f = 1; 

else 
StaticText1->Caption = StaticText1->Caption + "4"; 

// "5" tugmasiga 
void __fastcall TForm1::Btn5Click(TObject *Sender) 

if ( f == 0) 

StaticText1->Caption = "5"; 
f = 1; 



else 
StaticText1->Caption = StaticText1->Caption + "5"; 

// "6"tugmasiga 
void __fastcall TForm1::Btn6Click(TObject *Sender) 

if ( f == 0) 

StaticText1->Caption = "6"; 
f = 1; 

else 
StaticText1->Caption = StaticText1->Caption + "6"; 

// "7" tugmasiga 
void __fastcall TForm1::Btn7Click(TObject *Sender) 

if ( f == 0) 

StaticText1->Caption = "7"; 
f = 1; 

else 
StaticText1->Caption = StaticText1->Caption + "7"; 

// "8"tugmasiga 
void __fastcall TForm1::Btn8Click(TObject *Sender) 



if ( f == 0) 

StaticText1->Caption = "8"; 
f = 1; 

else 
StaticText1->Caption = StaticText1->Caption + "8"; 

// "9" tugmasiga 
void __fastcall TForm1::Btn9Click(TObject *Sender) 

if ( f == 0) 

StaticText1->Caption = "9"; 
f = 1; 

else 
StaticText1->Caption = StaticText1->Caption + "9"; 

// "," tugmasiga 
void __fastcall TForm1::BtnkClick(TObject *Sender) 

if ( f == 0) 

StaticText1->Caption = "0,"; 
f = 1; 



else 

Yüklə 181,19 Kb.

Dostları ilə paylaş:
1   ...   4   5   6   7   8   9   10   11   12




Verilənlər bazası müəlliflik hüququ ilə müdafiə olunur ©www.genderi.org 2024
rəhbərliyinə müraciət

    Ana səhifə