41223216 cp2023

  • Home
    • SMap
    • reveal
    • blog
  • About
  • w5
  • w6
  • w7
  • w12
  • w13
  • w15
  • w16
  • c_ex
  • ANSIC
    • 1.姓名、出生日期和手機號碼
    • 2.寫出 C 程式來計算高10英吋、寬10英吋的矩形的周長和面積
    • 3.反轉數字
    • 4.日期轉換為年、週和日
    • 5.總和
    • 6.列出前60個自然數
    • 7.輸入年份產生日曆
    • 8.猜數字
    • 9.判斷三角形
    • 10.檢查一個數字是否為質數
  • Brython
1.姓名、出生日期和手機號碼 << Previous Next >> 3.反轉數字

2.寫出 C 程式來計算高10英吋、寬10英吋的矩形的周長和面積

#include <stdio.h> 

/* 
   Variables to store the width and height of a rectangle in inches 
*/
int width;          
int height;         

int area;           /* Variable to store the area of the rectangle */
int perimeter;      /* Variable to store the perimeter of the rectangle */

int main() {
    /* Assigning values to height and width */
    height = 10;
    width = 10;

    /* Calculating the perimeter of the rectangle */
    perimeter = 2*(height + width);
    printf("Perimeter of the rectangle = %d inches\n", perimeter);

    /* Calculating the area of the rectangle */
    area = height * width;
    printf("Area of the rectangle = %d square inches\n", area);

    return(0);
}

1.姓名、出生日期和手機號碼 << Previous Next >> 3.反轉數字

Copyright © All rights reserved | This template is made with by Colorlib