Skip to content

Instantly share code, notes, and snippets.

@hocarm
Last active May 1, 2018 02:03
Show Gist options
  • Select an option

  • Save hocarm/c686ed1218f4239b37acb6a387d1d7a0 to your computer and use it in GitHub Desktop.

Select an option

Save hocarm/c686ed1218f4239b37acb6a387d1d7a0 to your computer and use it in GitHub Desktop.
unsigned long Calc_Area(unsigned long s);
int main(void) {
unsigned long side; // độ dài bức tường đơn vị met
unsigned long area; // diện tích căn phòng đơn vị met vuô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);
}
// Tính diện tích căn phòng
// Input: độ dài 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);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment