Ats22-07 nazarov xurshidbek


Download 475.28 Kb.
Sana19.01.2023
Hajmi475.28 Kb.
#1102333
Bog'liq
1-Amaliy mashg\'ulot ORTIQBOYEVA SEVINCH dasturlash


1-topshiriq
ATS22-07 NAZAROV XURSHIDBEK

  1. (Ishorani aniqlang). Foydalanuvchi tomonidan butun son kiritilganda, mazkur son manfiy yoki musbat son ekanligini chop etuvchi dastur tuzing. (Algoritm blok-sxemasi va dastur kodi tuzilishi va natija chop etilishi shart).

s=Manfiy son

s=Musbat son

a>0

a,s

Boshlash



S




Tugash

#include


#include
using namespace std;
int main(){
int a;
cout<<"Sonni kiriting:",cin>>a;
string s;
if(a>0){
s="musbat son";
}
else if(a<0){
s="manfiy son";
}
else{
s="Musbat ham manfiy han emas";
}
cout<

}



2. (Algebra: Kvadrat tenglamani hisoblang). Kvadrat tenglamaning ax2 + bx + c = 0 ildizlarini toping:


#include
#include
using namespace std;
int main ()
{
double a,b,c,x1,x2,d;
cout<<"ax^2+bx+c=0"<cout<<"a=";
cin>>a;
cout<<"b=";
cin>>b;
cout<<"c=";
cin>>c;
d=(b*b-4*a*c);
if(d>0){
x1=((-b)+sqrt(b*b-4*a*c))/(2*a);
x2=((-b)-sqrt(b*b-4*a*c))/(2*a);
cout<<"tenglamaning birinchi yechimi:"<<" "<cout<<"tenglamaning ikkinchi yechimi:"<<" "<else if(d==0){
x1=(-b)/(2*a);
cout<<"Tenglamaning ildizlari ozaro teng va "<}
else
cout<<"yechimga ega emas";
return 0;
}



3.(Koordinata) OX va OY koordinata o'qlarida yotmaydigan nuqta berilgan. Nuqta joylashgan koordinata choragi aniqlansin.
#include
using namespace std;
int main ()
{
double x,y;
cout<<"Kordinatalarni kiriting"<cout<<"x=";
cin>>x;
cout<<"y=";
cin>>y;
if (x>0 && y>0){
cout<<"I chorak";
}
else if (x>0 && y<0){
cout<<"IV chorak";
}
else if (x<0 && y<0){
cout<<"III chorak";
}
else if (x<0 && y>0){
cout<<"II chorak";
}
else if (x==0 && y==0){
cout<<"Kordinatalar boshi";
}
else if(x==0){
cout<<"OY oqida yotadi.";
}
else{
cout<<"OX oqida yotadi";
}
return 0;
}
x

4. xonali son berilgan .Uning raqamlarini teskariga yozish dasturini tuzish lozim.


#include
#include
using namespace std;
int main ()
{
int a,b=0;
cin>>a;
while(a>0){
b=b*10+a%10;
a/=10;
}
cout<return 0;
}
5. (Sanoq sistemasi). O‘nlik sanoq sistemasida berilgan son ikkilik sanoq sistemasiga o‘tkazilsin. 0<=n<=100
#include
#include
using namespace std;
int main ()
{
int a,b=0,c=0;
cin>>a;
while(a>0){
b=b*10+a%2;
a/=2;
}
while(b>0){
c=c*10+b%10;
b/=10;
}
c;out<}

Download 475.28 Kb.

Do'stlaringiz bilan baham:




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