Viết chương trình(cấu trúc rẽ nhánh) tính tổng a+b nếua a;b dương
K
Khách
Hãy nhập câu hỏi của bạn vào đây, nếu là tài khoản VIP, bạn sẽ được ưu tiên trả lời.

Những câu hỏi liên quan

23 tháng 12 2021
Câu 2:
#include <bits/stdc++.h>
using namespace std;
double a,b,c,delta,x1,x2;
int main()
{
//freopen("PTB2.inp","r",stdin);
//freopen("PTB2.out","w",stdout);
cin>>a>>b>>c;
delta=(b*b-4*a*c);
if (delta<0) cout<<"-1";
if (delta==0) cout<<fixed<<setprecision(5)<<(-b/(2*a));
if (delta>0)
{
x1=(-b-sqrt(delta))/(2*a);
x2=(-b+sqrt(delta))/(2*a);
cout<<fixed<<setprecision(5)<<x1<<" "<<fixed<<setprecision(5)<<x2;
}
return 0;
}

24 tháng 12 2021
Cấu trúc rẽ nhánh:
if <điều kiện> do <câu lệnh 1>
else <câu lệnh 2>;
uses crt;
var a,b:real;
begin
clrscr;
write('nhap a'); readln(a);
write('nhap b'); readln(b);
If a > 0 and b > 0 then write('Tong a va b: ',a+b);
End.
(đưa vào Pascal duyệt CT xem có mắc lỗi gì ko...nếu sai thì tự sửa ^^!)
;)) c'ơn bn, chỉ sai vafi loi