3- lab topshiriqlari if, if else operatorlariga doir topshiriqlar
Download 111 Kb.
|
1 2
Bog'liqlabaratoriya
3- lab_ topshiriqlari if, if else operatorlariga doir topshiriqlar
Dastur kodi: #include #include using namespace std; int main(){ float y, m, n ,d; cout<<"m= "; cin>>m; cout<<"n= "; cin>>n; cout<<"d= "; cin>>d; if(d>1){ y=pow((n*m*m+d),2); } if(d<=1){ y=d/(n*n+m*m); } cout<<"y= "< }
Natijasi: m= 1
n= 2 d= 3
y= 25 m= 4
n= 7 d= 0.2
y= 0.00307692
Dastur kodi: #include using namespace std; int main(){ int a,b,c; cout<<"a= "; cin>>a; cout<<"b= "; cin>>b; cout<<"c= "; cin>>c; if( (a<=b)&& (b <= c) || (a>=b) && (b >= c) ){ a*=2;
b*=2; c*=2;
} else{
a*=-1; b*=-1;
c*=-1; } cout<<"a= "<
cout<<"c= "< return 0;
}
Natijasi: b= 2
a= 2
c= 6
b= 2
a= 6
c= 2
b= 1
a= -3
c= -2
|
1 2
Ma'lumotlar bazasi mualliflik huquqi bilan himoyalangan ©fayllar.org 2024
ma'muriyatiga murojaat qiling
ma'muriyatiga murojaat qiling