1-misol Vazifa: C++ tilning shartli operatorlari va mantiqiy amallari yordamida berilgan A(x,y) nuqtaning shtrihlangan sohaga tegishli yoki tegishli emasligini aniqlovchi dastur yozing. Yechilishi


Download 0.77 Mb.
Sana18.02.2023
Hajmi0.77 Mb.
#1211545
Bog'liq
abdurahmon 2-topshiriq


1-misol
Vazifa: C++ tilning shartli operatorlari va mantiqiy amallari yordamida berilgan A(x,y) nuqtaning shtrihlangan sohaga tegishli yoki tegishli emasligini aniqlovchi dastur yozing.


Yechilishi:

#include
#include
using namespace std;
int main() {
double x,y,z;
cout<<"x="; cin>>x;
cout<<"y="; cin>>y;
z=fabs(x);
if ( x<=1 && x>=-1 && y>=z )
cout<<"kiradi";
else
cout<<"kirmaydi";
return 0;
}





2-topshiriq. Ichma ich joylashgan takrorlash operatorlaridan foydalanib rasmda ko’rsatilganlarni chop qiluvchi dastur tuzing



Yechish:


#include
#include
using namespace std;

int main() {
int x;
for (int i = 1; i<=4; i++ ){
for (int j=1; j<=4; j++ ){
x += 1 ;
if( ( x % 5 == 1 ) || ( x % 10 == 1 ) ){
cout<<" 0 "; }
else{
cout<<" "<
}
}
cout<
}
return 0;
}



3-topshiriq

#include
#include
using namespace std;
/* run this program using the console pauser or add your own getch, system("pause") or input loop */
int perimetr(int e){
return 4*e;
}
int yuza(int e){
return e*e;
}

int main(){
int a, b, c, d ,e;
cout << "kvadrat tomonini kirting= ";
cin >> a;
cout <<"perimetr = " << perimetr(a) << endl;
cout <<"yuza = " << yuza(a) << endl;
return main();
}

Download 0.77 Mb.

Do'stlaringiz bilan baham:




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