0% found this document useful (0 votes)
8 views4 pages

C Programming Exercises Collection

Uploaded by

Loan Kim
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
8 views4 pages

C Programming Exercises Collection

Uploaded by

Loan Kim
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 4

Bài 1

#include <stdio.h>
#include <math.h>
main() {
float x, S;
printf ("Nhap so thuc x = ");
scanf("%f", &x);
S = 1 + 9 * x - 2 * sin(x) + x * x - exp(x);
printf ("Gia tri cua bieu thuc la: %o.2f ", S);
}

Bài 2
#include <stdio.h>
#include <math.h>
main() {
float R, C, S;
printf("Nhap do dai ban kinh R = ");
scanf("%f", &R);
C = 2*R*M_PI;
S = M_PI*R*R;
printf("\nChu Vi hinh tron la: %0.2f", C);
printf("\nDien tich hinh tron la: %0.2f", S);
}

Bài 3
#include <stdio.h>
#include <math.h>
main() {
float a, b, c, p ,S, gocA, gocB, gocC;
printf("\nNhap do dai canh a: "); scanf("%f", &a);
printf("\nNhap do dai canh b: "); scanf("%f", &b);
printf("\nNhap do dai canh c: "); scanf("%f", &c);
p = (a+b+c)/2;
S = sqrt(p*(p-a) * (p-b) * (p-c));
gocA = acos((a*a + b*b + c*c) / 2*b*c) * 180/M_PI;
gocB = acos((a*a + c*c - b*b) / 2*a*c) * 180/M_PI;
gocC = acos((a*a + b*c - c*c) / 2*a*b) * 180/M_PI;
printf("\ngoc a = %0.2f", gocA);
printf("\ngoc b = %0.2f", gocB);
printf("\ngoc c = %0.2f", gocC);

Bài 4
#include <stdio.h>
#include <math.h>
main() {
int n, t5, t2, t1, t;
printf("Nhap tong so tien: :");
scanf("%d", &n);
t5 = n/500000;
t2 = (n%500000) / 200000;
t1 = ((n%500000) % 200000) / 100000;
t = (((n%500000) % 200000) % 100000) / 50000;
printf("\nTo 500.000 la %d", t5);
printf("\nTo 200.000 la %d", t2);
printf("\nTo 100.000 la %d", t1);
printf("\nTo 50.000 la %d", t);
}

Bài 5
#include <stdio.h>
#include <math.h>
main() {
int n, h, m, s;
printf("Nhap so giay: ");
scanf("%d", &n);
h = n/3600;
m = (n%3600) / 60;
s = (n%3600) % 60;
printf("Gio, phut, giay la: %02d:%02d:%02d",h, m, s);
}

Bài 6
#include <stdio.h>
main() {
float a, b, c;
printf("Nhap a : ");
scanf("%f", &a);
printf("Nhap b : ");
scanf("%f", &b);
printf("Nhap c : ");
scanf("%f", &c);
printf("So lon nhat la: %0.2f\n", a>b ? (a>c ? a : c) :(b>c ? b:c));
}

Bài 7
#include<stdio.h>
main() {
int l, tl, nc, nl;
printf("Nhap luong ngay cong = ");
scanf("%d",&l);
printf("Nhap so ngay cong quy dinh= ");
scanf("%d",&nc);
printf("Nhap so ngay lam = ");
scanf("%d",&nl);
tl = nl>nc ? (l*nc)+ 2*l*(nl-nc) : l*nc;
printf("so tien luong se la: %d\n",tl);
}

You might also like