3- lab topshiriqlari if, if else operatorlariga doir topshiriqlar


Download 111 Kb.
bet1/2
Sana05.12.2020
Hajmi111 Kb.
#160004
  1   2
Bog'liq
labaratoriya


3- lab_ topshiriqlari
if, if else operatorlariga doir topshiriqlar

5

;

1

m=1

n=2

d=3

Y=25.000

2

m=4

n=7

d=0.2

Y=0.003

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= "<

return main();

}


Natijasi:

m= 1


n= 2

d= 3


y= 25

m= 4


n= 7

d= 0.2


y= 0.00307692



5

Uchta x, y va z haqiqiy sonlar berilgan, agar ular monoton bo‘lsa ularning qiymatlari ikkilantirilsin, aks holda har bir o‘zgaruvchining ishorasi qarama-qarshisiga almashtirilsin.

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<<"b= "<

cout<<"c= "<

return 0;

}

Natijasi:



a= 1

b= 2


c= 3

a= 2


b= 4

c= 6


a= 3

b= 2


c= 1

a= 6


b= 4

c= 2


a= 3

b= 1


c= 2

a= -3


b= -1

c= -2




Download 111 Kb.

Do'stlaringiz bilan baham:
  1   2




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