Tomonlari bilan berilgan uchburchakning perimetri va yuzasini hisoblang


Download 14.65 Kb.
Sana06.11.2023
Hajmi14.65 Kb.
#1750142
Bog'liq
6-amaliy Akobir c


6-topshriq

  1. Tomonlari bilan berilgan uchburchakning perimetri va yuzasini hisoblang.

#include
#include

int main() {


double a, b, c;

// Tomonlarni o'qish


std::cout << "Uchburchak tomonini kiriting (a): ";
std::cin >> a;
std::cout << "Uchburchak tomonini kiriting (b): ";
std::cin >> b;
std::cout << "Uchburchak tomonini kiriting (c): ";
std::cin >> c;

// Perimetrni hisoblash


double P = a + b + c;

// Yuzani hisoblash


double S = sqrt(P * (P - a) * (P - b) * (P - c));

// Natijalarni chiqarish


std::cout << "Uchburchak perimetri (P): " << P << std::endl;
std::cout << "Uchburchak yuzasi (S): " << S << std::endl;

return 0;


}

  1. a, b, c sonlari berilgan. Ularning manfiylarini 2 marta oshiring, musbatlarini 2 ga bo‘ling, nolga teng bo‘lganlarini o‘zgarishsiz qoldiring.

#include

int main() {


int a, b, c;

// a, b, va c ni o'qish


std::cout << "a ni kiriting: ";
std::cin >> a;
std::cout << "b ni kiriting: ";
std::cin >> b;
std::cout << "c ni kiriting: ";
std::cin >> c;

// Manfiy sonlarni 2 marta oshirish


if (a < 0) {
a = a * 2;
}
if (b < 0) {
b = b * 2;
}
if (c < 0) {
c = c * 2;
}

// Musbat sonlarni 2 ga bo'lish


if (a > 0) {
a = a / 2;
}
if (b > 0) {
b = b / 2;
}
if (c > 0) {
c = c / 2;
}

// Natijalarni chiqarish


std::cout << "Natijalar: a=" << a << ", b=" << b << ", c=" << c << std::endl;

return 0;


}

Download 14.65 Kb.

Do'stlaringiz bilan baham:




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