Skip to content

Instantly share code, notes, and snippets.

@hocarm
Last active May 1, 2018 02:32
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save hocarm/c34f6ea6e0daab0073fc5fb834e43484 to your computer and use it in GitHub Desktop.
Save hocarm/c34f6ea6e0daab0073fc5fb834e43484 to your computer and use it in GitHub Desktop.
// Tính diện tích căn phòng hình vuông
// Input: Kích thước căn phòng (kiểu unsigned long) đơn vị mét
// Output: Diện tích căn phòng (kiểu unsigned long) đơn vị mét vuông
unsigned long Calc_Area(unsigned long s) {
unsigned long result;
result = s*s;
return(result);
}
int main(void) {
unsigned long side; // Kích thước căn phòng
unsigned long area; // Diện tích căn phòng
UART_Init(); // gọi subroutine để init uart
printf("This program calculates areas of square-shaped rooms\n");
side = 3;
area = Calc_Area(side);
printf("\nArea of the room with side of %ld m is %ld sqr m\n",side,area);
side = side+2;
area = Calc_Area(side);
printf("\nArea of the room with side of %ld m is %ld sqr m\n",side,area);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment