Đây là chương trình lập trình với pascal nah!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
???? Viết chương trình tính tổng S=12+22+32+......+n2
Mình thanks trước nah
Viết chương trình tính tổng S=12+22+32+…+n2 Với n là số nguyên dương được nhập vào từ bàn phím
#include <bits/stdc++.h>
using namespace std;
long long n,i,s;
int main()
{
cin>>n;
s=0;
for (i=1; i<=n; i++) s=s+i*i;
cout<<s;
return 0;
}
Var s,i,n:longint;
Begin
Write('Nhap so luong so n = ');readln(n);
For i:=1 to n do
s:=s+i*i;
Write('Tong la ',s);
Readln;
End.
Câu 1: Viết chương trình tính tổng dãy số sau: S=12+22+...+n2.
Câu 2: Viết chương trình tính tổng nghịch đảo N số nguyên đầu tiên.
Câu 1:
var i,n:integer;
s:longint;
begin
write('Nhap n = ');readln(n);
for i:=1 to n do
s:=s+(i*10+2);
write('S = ',s);
readln;
end.
Câu 2:
var i,n:integer;
s:real;
begin
write('Nhap n = ');readln(n);
for i:=1 to n do s:=s+1/n;
write('tong la ',s:10:2);
readln;
end.
Câu 4: Cho S = 12 + 22 + 32 + … + n2, với n là một số tự nhiên nhập từ bàn phím. Hãy viết chương trình sử dụng lệnh lặp While…do để tính tổng trên?
uses crt;
var i,n,s:integer;
begin
clrscr;
readln(n);
s:=0;
i:=0;
while i<=n do
begin
i:=i+1;
s:=s+i*i;
end;
writeln(s);
readln;
end.
#TK
uses crt;
var s,i:integer;
begin
clrscr;
s:=0;
for i:=3 to 97 do
s:=s+i;
write(s);
readln;
end.
uses crt;
var s,i:integer;
begin
clrscr;
s:=0;
for i:=3 to 97 do
s:=s+i;
writeln(s);
readln;
end.
b1;tim ssh cua day so cach deu tren cong thuc lop 5:(97-3):khoang canh +1; :))
b2;tinh tong bang cong thuc lop 5 sau : tong=(so dau + so cuoi)*ssh/2;
b3; xuat ra :)))
Viết chương trình tính tổng sau S=1+32+52+72+....+(2n-1)2
Pascal
uses crt;
var i,n,s:longint;
begin
clrscr;
readln(n);
s:=0;
for i:=1 to n do
s:=s+sqr((2*i-1));
writeln(s);
readln;
end.
Viết chương trình nhập vào 2 số nguyên a, b và xuất ra màn hình yêu cầu sau:
a. Tính tổng, tích 2 số vừa nhập.
b. Thực hiện phép chia lấy phần dư với 2 số vừa nhập.
Giúp mình viết chương trình Pascal theo yêu cầu trên với mn ơi. Thanks mn nhiều<33
Viết chương trình tính S=1+2_+100 của chương trình pascal
uses crt;
var s,i:integer;
begin
clrscr;
s:=0;
for i:=1 to 100 do s:=s+i;
writeln(s);
readln;
end.
#include <iostream>
using namespace std;
int main () {
int tong = 0;
for (int i = 1 ; i <= 100; i++) tong = tong + i;
cout << " Tong S = " << tong;
return 0;
}
Chạy chương trìnhTong S = 5050
Viết chương trình bằng ngôn ngữ lập trình Pascal tính tổng các số từ 1 đến n, biết n là số tự nhiên được nhập từ bàn phím
Var i,n:integer;
s:longint;
Begin
Write('n = ');readln(n);
For i:=1 to n do
s:=s+i;
Write('Tong la ',s);
Readln;
End.
Em sử dụng pascal, nếu đc thì có thể ghép bốn câu lại với nhau giúp em :3
Bài1: viết chương trình tính tổng(tích) của N số tự nhiên.
Bài2: viết chương trình tính tổng (tích) từ số n đến m
Bài3: viết chương trình tính tổng (tích) từ 10 đến 25
Bài4: viết chương trình tính tổng các số lẻ(hoặc chẵn) của N số tự nhiên, N được nhập từ bàn phím.
1.
Var i ,n : integer;
S , T : real;
Begin
Write ('n:') ;
Read (n) ;
S:= 0;
T:= 1;
For i:= 1 to n do
S:= S + i;
T:= T * i;
Writeln (' Tong cua ' ,n,' , S );
Writeln (' Tich của ' ,n,', T );
Readln;
End.
2.
program SumAndProductOfNumbers;
var
n, m, i, sum, product: integer;
begin
writeln('Enter the values of n and m: ');
readln(n, m);
sum := 0;
product := 1;
for i := n to m do
begin
sum := sum + i;
product := product * i;
end;
writeln('The sum of numbers from ', n, ' to ', m, ' is: ', sum);
writeln('The product of numbers from ', n, ' to ', m, ' is: ', product);
end.
3.
program SumAndProductOfNumbers;
var
i, sum, product: integer;
begin
sum := 0;
product := 1;
for i := 10 to 25 do
begin
sum := sum + i;
product := product * i;
end;
writeln('The sum of numbers from 10 to 25 is: ', sum);
writeln('The product of numbers from 10 to 25 is: ', product);
end.
Làm giúp mình bài này với ạ,mình đang cần gấp
Em hãy viết chương trình Pascal để tính tổng của dãy số An(A1,A2,A3, ...,An) với n được nhập từ bàn phím.Em hãy viết chương trình để in ra tổng các số chẵn của dãy An
uses crt;
var x,n,i,t:integer;
begin
clrscr;
readln(n);
t:=0;
for i:=1 to n do
begin
readln(x);
if x mod 2=0 then t:=t+x;
end;
writeln(t);
readln;
end.
program ideone;
var i,n,x,res:longint;
begin
readln(n);
res:=0;
for i:=1 to n do
begin
read(x);
if x mod 2 = 0 then
res:=res+x;
end;
write(res);
end.