Mavzu : C++ tilde malumotlarning asosiy turlari bilan amallar bajarish


Download 0.62 Mb.
Sana15.06.2023
Hajmi0.62 Mb.
#1485807
Bog'liq
amaliy dasturlash


5 - Amaliy mashg’ulot
Mavzu : C++ tilde malumotlarning asosiy turlari bilan amallar bajarish
3 bo’lim 1 misol
#include
// Hasanov Asror 213 - guruh talabasi
using namespace std;
int main()
{ int a, v, s;
cout << "kub tomoni a ni kiriting = "; cin >> a;
v = a * a * a; s = 6 * a * a;
cout << "v hajm = "<< v << endl;
cout << "s yon tomonlar yuzasi = "<< s << endl;
return 0;
}
3 bo’lim 2 misol
#include
#include
// Hasanov Asror 213 - guruh talabasi
using namespace std;
int main()
{ int a, b, c, s;
cout << "a ni kiriting = "; cin >> a;
cout << "b ni kiriting = "; cin >> b;
c = sqrt (a * a + b * b); s = (a * b)/2;
cout << "c gipotenuza = "<< c << endl;
cout << "s yuzasi = "<< s << endl;
return 0; }

3 bo’lim 3 misol
#include
#include
// Hasanov Asror 213 - guruh talabasi
using namespace std;
int main()
{ int arif, geom, a, b;
cout << "a ni kiriting = "; cin >> a;
cout << "b ni kiriting = "; cin >> b;
arif =(a + b )/2; geom = sqrt(a * b);
cout << "arif = "<< arif << endl;
cout << "geom = "<< geom << endl;
return 0;
}
3 bo’lim 4 misol
#include
#include
// Hasanov Asror 213 - guruh talabasi
using namespace std;
int main()
{ int t, h, g;
cout << "h ni kiriting = "; cin >> h;
cout << "g ni kiriting = "; cin >> g;
t= sqrt(2 * h/g);
cout << "t = "<< t << endl;
return 0;}

3 bo’lim 5 misol
#include
#include
// Hasanov Asror 213 - guruh talabasi
using namespace std;
int main()
{ float s, a;
cout << "a ni kiriting = "; cin >> a;
s= (sqrt(3)* a * a)/4;
cout << "s = "<< s << endl;
return 0;
}

3 bo’lim 6 misol
#include
#include
// Hasanov Asror 213 - guruh talabasi
using namespace std;
int main()
{ float const pi=3.141519;
int t, l, g;
cout << "l ni kiriting = "; cin >> l;
cout << "g ni kiriting = "; cin >> g;
t= 2 * pi * sqrt( l/g);
cout << "t = "<< t << endl;
return 0;
}

3 bo’lim 7 misol
#include
#include
// Hasanov Asror 213 - guruh talabasi
using namespace std;
int main()
{
int t, t1, t2, v, v1, v2;
cout << "t1 ni kiriting = "; cin >> t1;
cout << "t2 ni kiriting = "; cin >> t2;
cout << "v1 ni kiriting = "; cin >> v1;
cout << "v2 ni kiriting = "; cin >> v2;
v = v1 + v2; t = ((v1 + v2) * t2 + v1 * t1)/(2 *v1 + v2);
cout << "t = "<< t << endl;
cout << "v = "<< v << endl;
return 0;}

3 bo’lim 8 misol
#include
#include
// Hasanov Asror 213 - guruh talabasi
using namespace std;
int main()
{ float r, r1, r2, r3, r4;
cout << "r1 ni kiriting = "; cin >> r1;
cout << "r2 ni kiriting = "; cin >> r2;
cout << "r3 ni kiriting = "; cin >> r3;
cout << "r4 ni kiriting = "; cin >> r4;
r = (r1 * r2 * r3)/(r1*r2 + r2*r3 + r1*r3);
cout << "r = "<< r << endl;
return 0;}

3 bo’lim 9 misol
#include
#include
using namespace std;
int main()
{ float l, x, y;
cout << "x ni kiriting ="; cin >> x;
cout << "y ni kiriting ="; cin >> y;
l = (fabs(x) + fabs (y)) / (1 + fabs (x * y));
cout << "l ="<< l << endl;
return 0;}

6 - Amaliy mashg’ulot
Mavzu : C ++ tilida chiziqli dasturlash
5 bo’lim 1 misol
#include
using namespace std;
int main()
{ int n, a;
cout << "n ni kiriting "; cin >> n;
a = n /100;
cout << "a yuzlik raqami ="<< a << endl;
return 0;}

5 bo’lim 2 misol
#include
// Hasanov Asror 213 -guruh talabasi
using namespace std;
int main()
{ int n, a, b, s;
cout << "n ni kiriting "; cin >> n;
a = n % 10;
b = n /10;
s =a + b;
cout << "s birinchi va oxiri raqamlari yig'indisi ="<< s << endl;
return 0;}

5 bo’lim 3 misol
#include
#include
#include
// hasanov Asror 213 -guruh talabasi
using namespace std;
int main()
{ float p, s, a, b, c;
cout << "a ni kiriting "; cin >> a;
cout << "b ni kiriting "; cin >> b;
cout << "c ni kiriting "; cin >> c;
p =(a + b + c) / 2;
s = sqrt(p*(p - a)*(p - b)*(p - c));
cout << setprecision (2)<< fixed<< s << endl;
return 0;}

5 bo’lim 4 misol
#include
#include
// hasanov Asror 213 -guruh talabasi
using namespace std;
int main()
{ float r, a, b, c;
cout << "a ni kiriting "; cin >> a;
cout << "c ni kiriting "; cin >> c;
b = sqrt(c * c - a * a);
r = (a + b + c)/ (a * b);
cout << "b ="<< b << endl;
cout << "r ="<< r << endl;
return 0;}

5 bo’lim 5 misol
#include
#include
// hasanov Asror 213 -guruh talabasi
using namespace std;
int main()
{ float s, a, d, n;
cout << "a ni kiriting "; cin >> a;
cout << "d ni kiriting "; cin >> d;
cout << "n ni kiriting "; cin >> n;
s = ((2 * a + d * (n - 1)) * n) / 2;
cout << "s ="<< s << endl;
return 0;}

5 bo’lim 6 misol
#include
#include
// hasanov Asror 213 -guruh talabasi
using namespace std;
int main()
{ float s, x1, y1, x2, y2;
cout << "x1 ni kiriting "; cin >> x1;
cout << "y1 ni kiriting "; cin >> y1;
cout << "x2 ni kiriting "; cin >> x2;
cout << "y2 ni kiriting "; cin >> y2;
s = sqrt (pow((x2-x1),2) + pow((y2-y1),2));
cout << "s ="<< s << endl;
return 0;}

5 bo’lim 7 misol
#include
#include
// hasanov Asror 213 -guruh talabasi
using namespace std;
int main()
{ int s, a, b;
cout << "a ni kiriting "; cin >> a;
cout << "b ni kiriting "; cin >> b;
s = a / b;
cout << "s ="<< s << endl;
return 0;
}

5 bo’lim 8 misol
#include
#include
// hasanov Asror 213 -guruh talabasi
using namespace std;
int main()
{ int a, b; float s;
cout << "a ni kiriting "; cin >> a;
cout << "b ni kiriting "; cin >> b;
s = a % b;
cout << setprecision (4)<< fixed << s << endl;
return 0;}

5 bo’lim 9 misol
#include
#include
// hasanov Asror 213 -guruh talabasi
using namespace std;
int main()
{ int a1, b1, a, b;
cout << "a ni kiriting "; cin >> a;
cout << "b ni kiriting "; cin >> b;
a1 = b; b1 = a;
cout << "a1 ="<< a1 << endl;
cout << "b1 ="<< b1 << endl;
return 0;
}

7 - Amaliy mashg’ulot


Mavzu : C++ tilde shartli va shartsiz o’tish operatorlari. Tanlash operatorlari
10 bo’lim 1 misol
#include
#include
// Hasanov Asror 213 guruh talabasi
using namespace std;
int main()
{ float x, y, max, min;
cout << "x ni kiriting = "; cin >> x;
cout << "y ni kiriting = "; cin >> y;
max = (x > y) ? x : y;
min = (y > x) ? x : y;
cout << "max = " << max << endl;
cout << "min = " << min << endl;
return 0;
}

10 bo’lim 2 miso
#include
#include
// Hasanov Asror 213 guruh talabasi
using namespace std;
int main()
{ float x, y, z, max, min;
cout << "x ni kiriting = "; cin >> x;
cout << "y ni kiriting = "; cin >> y;
cout << "z ni kiriting = "; cin >> z;
max = (x > y) ? x : y;
max = (max > z) ? max : z;
min = (x > y) ? x : y;
min = (min < z) ? min : z;
cout << "max = " << max << endl;
cout << "min = " << min << endl;
return 0;
}l

10 bo’lim .3 misol
#include
#include
// Hasanov Asror 213 guruh talabasi
using namespace std;
int main()
{ float x, y, z, max, min;
cout << "x ni kiriting = "; cin >> x;
cout << "y ni kiriting = "; cin >> y;
cout << "z ni kiriting = "; cin >> z;
max = ((x + y + z) > (x*y*z)) ? (x + y + z): (x*y*z);
min = pow(((((x + y + z)/2) < (x*y*z)) ? (x + y + z): (x*y*z)),2) + 1;
cout << "max = " << max << endl;
cout << "min = " << min << endl;
return 0;
}

10 bo’lim 4 misol
#include
#include
// Hasanov Asror 213 guruh talabasi
using namespace std;
int main()
{ float x, y, z;
cout << "x ni kiriting = "; cin >> x;
cout << "y ni kiriting = "; cin >> y;
cout << "z ni kiriting = "; cin >> z;
{if (x>y>z) cout << "qanoatlantiradi"<< endl;
else cout << "qaoatlantirmadi"<< endl;}
return 0;
}

10 bo’lim 5 misol
#include
//#include
// Hasanov Asror 213 guruh talabasi
using namespace std;
int main()
{ int a, b, c;
cout << "a ni kiriting = "; cin >> a;
cout << "b ni kiriting = "; cin >> b;
cout << "c ni kiriting = "; cin >> c;
if (a >= b >= c)
cout << (2*a) << (2*b) << (2*c) << endl;
else cout<< a << b << c <return 0;
}

10 bo’lim 6 misol
#include
#include
// Hasanov Asror 213 guruh talabasi
using namespace std;
int main()
{ int x, y;
cout << "x ni kiriting = "; cin >> x;
cout << "y ni kiriting = "; cin >> y;
if (x > y)
cout<< x-y << endl;
else
cout<< y-x +1 << endl;
return 0;
}

10bo’lim.7 misol
#include
#include
// Hasanov Asror 213 guruh talabasi
using namespace std;
int main()
{ int x, y;
cout << "x ni kiriting = "; cin >> x;
cout << "y ni kiriting = "; cin >> y;
if (x > y)
cout<< x << endl;
else
cout<< x << y << endl;

return 0;


}

10 bo’lim 8 misol
#include
#include
// Hasanov Asror 213 guruh talabasi
using namespace std;
int main()
{ int x, y, a;
cout << "x ni kiriting = "; cin >> x;
cout << "y ni kiriting = "; cin >> y;
if (x <= y)
cout<< "x = " << 0 << endl;
else
cout<< x << endl;
return 0;
}

8 – amaliy mashg’ulot
Mavzu: C++ tilida takrorlash operatorlari
15 bo’lim 1 misol
#include
// Hasanov Asror 213 –guruh talabasi
using namespace std;
int main()
{ int n;
cout <<"n ni kiriting ="; cin >> n;
for (int i = 1; i<=n ; i++)
if (n % i==0)
cout << i << endl;
return 0;
}

15 bo;lim 2 misol
#include
// Hasanov Asror 213 –guruh talabasi
using namespace std;
int main()
{ int n, s = 0;
cout <<"n ni kiriting ="; cin >> n;
for (int i = 1; i<=n ; i++)
if (n % i==0)
//cout << i << " "<< endl;
s += i;
cout << s << endl;
return 0;
}

15 bo’lim 3 misol
#include
// Hasanov Asror 213 –guruh talabasi
using namespace std;

int main()


{ int n, s = 0;
cout <<"n ni kiriting ="; cin >> n;
for (int i = 1; i < n ; i++)
if (n % i==0)
s+=i;
if(s==n)
cout << "mukammal son" << endl;
else cout << "mukammal son emas" << endl;
return 0;
}

15 bo’lim 4 misol
#include
#include
using namespace std;
//Hasanov Asror 213 guruh talabasi
int main()
{ int n,s=0;
cout << "n = "; cin>>n;
for (int i=1;i<=n;i++)
{
if (n%i==0)
{
s+=i;
}
}cout<<"yig`indi="<return 0;
}

15 bo’lim 5 misol

#include


// Hasanov Asror 213 –guruh talabasi
using namespace std;
int main()
{ int n, s = 0;
cout <<"n ni kiriting ="; cin >> n;
for (int i = 1; i <= n ; i++)
if ((i % 3==0)&&(i % 5!=0))
cout << i << endl;
else cout << "shart bajarilmayapti " << endl;
return 0;
}

15 bo’lim 6 misol


9- Amaliy mashg’ulot


Mavzu : C++ tilde bir o’lchovli massivlar
25 bo’lim a misol
#include
// Hasanov Asror 213 guruh talabasi
using namespace std;
int main()
{ int n;
int a[10];
cin>> n;
int s =0;
for (int i=0; i{
cout <<"a["<cin >> a[i];
s+=a[i];
}
cout << "s = " << s << endl;
return 0;
}

25 bo’lim b misol
#include
// Hasanov Asror 213 guruh talabasi
using namespace std;
int main()
{ int n;
int a[10];
cin>> n;
int s =1;
for (int i=0; i{
cout <<"a["<cin >> a[i];
s*=a[i];
}
cout << "s = " << s << endl;
return 0;
}
25 bo’lim b misol
#include
#include
// Hasanov Asror 213 guruh talabasi
using namespace std;

int main()


{ int n;
int a[10];
cin>> n;
int s =0;
for (int i=0; i < n; i++)
{
cout <<"a["<cin >> a[i];
s+=fabs(a[i]);
}
cout << "s = " << s << endl;
return 0;}

25 bo’lim d misol
#include
#include
// Hasanov asror 213 guruh talabsi
using namespace std;

int main()


{ int n;
int a[10];
cin>> n;
int s =1;
for (int i=0; i{
cout <<"a["<cin >> a[i];
s*=fabs(a[i]);
}
cout << "s = " << s << endl;
return 0;
}

25 bo’lim e misol
#include
#include
// Hasanov asror 213 guruh talabsi
using namespace std;

int main()


{ int n;
int a[10];
cin>> n;
int s =0;
for (int i=0; i{
cout <<"a["<cin >> a[i];
s+=pow(a[i],2);
}
cout << "s = " << s << endl;
return 0;
}

25 bo’lim f misol
#include
#include
// Hasanov Asror 213 guruh talabasi
using namespace std;
int main()
{ int n;
int a[10];
cin>> n;
int s1 =0,s2 = 1,s3=0;
for (int i=0; i{
cout <<"a["<cin >> a[i];
s1+=a[i];
s2*=a[i];
s3=s1+s2;

}
cout << "s3 = " << s3 << endl;


return 0;
}

25 bo’lim g misol
#include
#include
//Hasanov Asrouruh talabasir 213 g
using namespace std;
int main()
{ int n;
int a[100];
cout<<"n = "; cin>>n;
int s=0, y=0;
for (int i=0;i < n;i++)
{ cout <<"a["<cin>>a[i];
if (i%2==1) s+=(a[i]); else y+=(a[i]);
}
cout <return 0;
}

Download 0.62 Mb.

Do'stlaringiz bilan baham:




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