Bài 2.2:
 
Viết chương trình tính các tổng:

            S = 1/2 + 1/4 + .. + 1/(2k)
            Q = 1.1! + 2.2! +.. + n.n!

//Câu 2:
#include <stdio.h>
#include <math.h>
int main(void)
{
int k,n,i;
float S = 0;
int Q = 0;
int gt=1;

printf("Nhap k: ");scanf("%d",&k);
printf("Nhap n: ");scanf("%d",&n);

//Tinh tong
for(i=1;i<=k;i++) S+=1.0/(2*i);
for(i=1;i<=n;i++)
{
gt*=i;
Q+=i*gt;
}
printf("S = %.2f, Q = %d\n",S,Q);

return 0;
}
Coding: Hải Dớ