7.20.2554

เนื้อหาจากการประชุมครั้งที่ 4

โจทย์ 1 inverse matrix
- ประกาศฟังก์ชั่น void (ไม่ส่งค่ากลับ) เก็บตัวแปรชนิด float 4 ตัว
- รับค่าเมตริก 2*2
- ส่งค่า a11,a12,a21,a22 ไปให้ฟังก์ชั่นคำนวณ
- ที่ฟังก์ชั่น ประกาศตัวแปรเพิ่ม (c) เพื่อหา det a แล้วนำมาหาร a11,a12,a21,a22
จะได้ invers matrix ของ a จากนั้นแสดงค่าที่ได้


โจทย์ 2 แปลงพิกัดฉากเป็นพิกัดเชิงขั้ว แล้วนำค่าพิกัดเชิงขั้วที่ได้แปลงเป็นพิกัดฉาก
- เพิ่ม #include
- ประกาศฟังก์ชั่น cart2pol แปลงพิกัดฉาก -> เชิงขั้ว เก็บตัวแปรชนิด double 2ตัว
- ประกาศฟังก์ชั่น plo2cart แปลงเชิงขั้ว -> พิกัดฉาก เก็บตัวแปรชนิด double 2ตัว
- รับค่า x,y จากแป้นพิมพ์ จากนั้นส่งไปฟังก์ชั่น cart2pol จะได้ค่า r,theta (ประกาศเพิ่มในฟังก์ชั่น)
- ส่งค่า r,theta ไปฟังก์ชั่น pol2cart เพื่อแปลงกลับ



โจทย์ 3 คำนวณหา Molecular Weigth

- ประกาศฟังก์ชั่น CalculateWeightAminoAcid เพื่อเก็บตัวแปรชนิด int 5 ตัว จากนั้นรับค่าจากแป้นพิมพ์ แล้วทำการคำนวณและส่งค่ากลับมาเป็นตัวแปรชนิด float เพื่อแสดงค่าที่ส่งกลับมาในฟังก์ชั่นหลัก

8 ความคิดเห็น:

  1. วีรศักดิ์ ดังชนกนันท์23 กรกฎาคม 2554 เวลา 09:46

    #include "stdio.h"
    float MAX (float r);
    int main (void)
    {
    float r,area;
    printf("Enter Radius is : ");
    scanf("%f",&r);
    MAX(r);
    printf("Area is %.2f",area);
    }
    float MAX (float r)
    {
    float area,r;
    area=3.14*r*r;
    return area;
    }

    แสดงผล
    Enter Radius is 10
    Area is 314.00

    ตอบลบ
  2. ไม่ระบุชื่อ30 กรกฎาคม 2554 เวลา 14:42

    โปรแกรมหาพื้นที่ผิวข้างของกรวย

    #include"stdio.h"
    float surface(float r,float l);
    int main(void)
    {
    float r,l;
    printf("Enter radius : ");
    scanf("%f",&r);
    printf("Enter height slant : ");
    scanf("%f",&l);
    printf("The surface of cone is %f",surface(r,l));
    return 0;
    }
    float surface(float r,float l)
    {
    return (3.14*r*l)+(3.14*r*r);
    }


    ผลลัพธ์
    Enter radius : 5
    Enter height slant : 6
    The surface of cone is 172.699997



    (หัสรา วัจนะรัตน์ 5401011620542)

    ตอบลบ
  3. ไม่ระบุชื่อ1 สิงหาคม 2554 เวลา 10:21

    โปรแกรมคำนวณค่าdetโดยใช้ฟังก์ชันย่อยในการคำนวณฟังก์ชันหลักมีหน้าที่รับค่า
    #include
    float deta (float a11,float a12,float a21,float a22);
    int main (void)
    {
    float det,a11,a12,a21,a22;
    printf("\n __ __\n| |\n| a11 a12|\n| |\n| a21 a22|\n|__ __|\n\n");
    printf("Enter a11 = ");
    scanf("%f",&a11);
    printf("\n\nEnter a12 = ");
    scanf("%f",&a12);
    printf("\n\nEnter a21 = ");
    scanf("%f",&a21);
    printf("\n\nEnter a22 = ");
    scanf("\n\n\n%f",&a22);
    det=deta(a11,a12,a21,a22);
    printf("\n\n\nanswer is %f\n\n\n",det);
    return 0;
    }
    float deta (float a11,float a12,float a21,float a22)
    {
    float det;
    det=(a11*a22)-(a12*a21);
    return det;
    }
    (นาย ปลวัชร เปรมสิริอำไพ 54-010116-2033-0)

    ตอบลบ
  4. ไม่ระบุชื่อ1 สิงหาคม 2554 เวลา 20:03

    โปรแกรมหาปริมาตรกรวย
    #include"stdio.h"
    #define PI 3.14
    float volume (float r, float h);
    int main(void)
    {
    float r,h;
    printf("Enter Radius => ");
    scanf("%f"&r);
    printf("Enter Height => ");
    scanf("%f",&h);
    printf("Volume => %f ",volume(r,h));
    return 0;
    }
    volume(float r, float h)
    {
    return volume=PI*r*r*h;
    }

    ผลลัพธ์ คือ
    r=10
    h=2
    volume=628.000000
    แสดงผล คือ
    Enter Radius => 10
    Enter Height => 2
    Volume => 628.000000

    (น.ส. พรทิพย์ ทาบุตร 54-010116-2036-4)

    ตอบลบ
  5. คำนวณดัชนีมวลกาย
    #include
    float calculateBMI(float weight,float height);
    int main(void)
    {
    float weight,height,BMI;
    printf("Enter Weight :");
    scanf("%f",&weight);
    printf("Enter Height :");
    scanf("%f",&height);
    calculateBMI(weight,height);
    printf("BMI = %f\n",calculateBMI(weight,height));
    }

    float calculateBMI(float weight,float height)
    {
    float BMI;
    BMI = weight / (height*height);
    return BMI;
    }

    ผลคือ

    Enter Height : 1
    Enter Weight : 2
    BMI = 0.2500000

    (นาย เบญจพล ศรีสันติธรรม 54-010116-2059-3)

    ตอบลบ
  6. โปรแกรมหาปริมาตรทรงสี่เหลียมมุมฉาก
    #include
    float Volume of a cuboid (float wide,float long,float high);
    int main()
    {
    float wide,long,high;
    printf("Enter wide :");
    scanf("%f",&wide);
    printf("Enter long :");
    scanf("%f",&long);
    printf("Enter high :");
    scanf ("%f",&high);
    printf(" Volume of a cuboid is %.1f",Volume of a cuboid (wide,long, high));
    return 0;
    }
    float Volume of a cuboid (float wide,float long,float high)
    {
    float area;
    area=wide*long*high;
    return area;
    }
    การทำงาน
    Enter wide :2
    Enter long :2
    Enter high :2
    Volume of a cuboid is 8.0

    นายธน สุทธิธรรม 5401011630149

    ตอบลบ
  7. ไม่ระบุชื่อ8 กันยายน 2554 เวลา 18:26

    #include
    float kane(float a,float b);
    int main (void)
    {
    float a,b,sum;
    printf("Please enter number in a,b = \t");
    scanf("%f%f",&a,&b);
    sum=kane(a,b);
    printf("Result = %f",sum);
    }
    float kane(float a,float b)
    {
    float sum;
    sum=a*b;
    return sum;
    }
    ใส่ค่า 4 and 5
    ค่าที่ได้ คือ 20
    ศราวุฒิ คำเมือง 54-010116-2049-6

    ตอบลบ
  8. #include
    float electronic (float x,float y);
    int main (void)
    {
    float x,y,total;
    printf("Enter your Num in x,y = ");
    scanf("%f%f",&x,&y);
    total=electronic(x,y);
    printf("Result = %f",total);
    }
    float electronic(float x,float y)
    {
    float total;
    total = x*y;
    return total;
    }
    หลัง run
    พิมพ์ x 11 พิมพ์ y 11
    ค่าที่ได้ คือ 121
    (นายอาภากร กัณหา 54-010116-2062-3)

    ตอบลบ