Nhập 1 số thực nằm trong khoảng từ 1 đến 10 và yêu cầu nhập lại số đó nếu không thoả mãn
Hãy viết các câu lệnh Pascal yêu cầu người dùng nhập một số thực nằm trong khoảng từ 1 đến 10 và yêu cầu nhập lại nếu số đó không thuộc khoảng này.
uses crt;
var n:real;
begin
clrscr;
repeat
readln(n);
if (n<1) or (n>10) then writeln('Hay nhap lai');
until (1<=n) and (n<=10);
readln;
end.
Viết chương trình nhập vào một số chẵn lớn hơn 10 nhỏ hơn 70. Nếu nhập không đúng yêu cầu nhập lại? Sau đó tính tổng các số từ 1 đến số chẵn vừa nhập?
ai giúp e bài này với ạ
#include <bits/stdc++.h>
using namespace std;
long long n,i,t;
int main()
{
cin>>n;
if ((n>10) and (n<70))
{
t=0;
for (i=1; i<=n; i++)
if (i%2==0) t=t+i;
cout<<t;
}
else cout<<"Nhap lai";
return 0;
}
Viết CT nhập vào số nguyên dương n(n được nhập giá trị từ bàn phím), sau đó thực hiện các yêu cầu sau: a, nếu n=0 thì yêu cầu nhập lại số n b, tính tổng các số chẵn từ 1 đến n vừa nhập c, tính tích các số lẻ từ 1 đến n vừa nhập D, in các giá trị vừa tính được ra màn hình
uses crt;
var n,i,t,s:integer;
begin
clrscr;
repeat
readln(n);
until n<>0;
t:=0;
for i:=1 to n do if i mod 2=0 then t:=t+i;
writeln(t);
s:=1;
for i:=1 to n do
if i mod 2=1 then s:=s*i;
writeln(s);
readln;
end.
Em hãy viết chương trình Pascal nhập vào một số tự nhiên n thoả mãn 2<n<100, nếu sai yêu cầu nhập lại, tính và in ra các bội có 4 chữ số của n.
program TimBoi4ChuSo;
var
n, i: integer;
begin
repeat
writeln('Nhap vao so nguyen n (2<n<100): ');
readln(n);
until (n > 2) and (n < 100);
writeln('Cac boi cua ', n, ' co 4 chu so la: ');
for i := 1000 to 9999 do
begin
if i mod n = 0 then
writeln(i);
end;
end.
Nhập từ bàn phím số thực x biểu diễn điểm HS (0≤x≥10) và được làm tròn 1/4 điểm. Vd: các số nhập vào hợp lệ: 7.25, 6.5, 9.0, 8.75. Chương trình cảnh báo số nhập vào không hợp lệ và yêu cầu nhập lại và chỉ kết thúc khi số hợp lệ được nhập.
uses crt;
var x:real;
begin
clrscr;
repeat
write('Nhap diem:'); readln(x);
until (0<=x) and (x<=10) and ((frac(x)=25) or (frac(x)=5) or (frac(x)=75) or (frac(x)=0));
writeln(x:4:2);
readln;
end.
viết chương trình yêu cầu người sử dụng nhập vào 1 số trong khoảng từ 1 đến 10 và yêu cầu nhập lại nếu số không thỏa mãn
Program hotrotinhoc_hoc24;
var n: integer;
begin
write('Nhap so : '); readln(n);
while (n>=10) or (n<=1) do
begin
write('Nhap lai so : '); readln(n);
end;
readln
end.
Em hãy viết chương trình Pascal nhập vào một số tự nhiên n thoả mãn 0<n<100, nếu sai yêu cầu nhập lại, tính và in ra các bội có 4 chữ số của n.Giups vs ạ cần gấp
program MultiplesOfN;
var
n, i: integer;
begin
repeat
write('Nhap vao so nguyen duong n (0<n<100): ');
readln(n);
until (n > 0) and (n < 100);
writeln('Cac boi so cua ', n, ' co 4 chu so la:');
for i := 1000 to 9999 do
begin
if (i mod n = 0) then
begin
writeln(i);
end;
end;
readln;
end.
Em hãy viết chương trình Pascal nhập vào một số tự nhiên n thoả mãn 2<n<100, nếu sai yêu cầu nhập lại, tính và in ra các ước của n, nếu n chỉ có hai ước, hãy thông báo n là số nguyên tố.
Viết chương trình nhập vào số thực nằm trong khoảng 1 đến 5 . Yêu cầu nhận lại nếu số đó không thuộc khoảng này.
không dùng lệnh until....
Program HOC24;
var n: real;
begin
write('Nhap so thuc : '); readln(n);
while (n>=1) and (n>=5) do
begin
write('So khong nam trong khoang 1 den 5, nhap lai :');
readln(n);
end;
readln
end.