fork download
  1. #includPlot a graph between temperature (T) and distance from the left edge of the sample material (x) from 0 to L for the sample material in equilibrium from the initial temperature to the final temperature, with the left and right ends of the sample material having the initial temperature T1 and T2 and the final temperature T1’ and T2’ respectively, along with the change of the graph with respect to
  2. time from t=0 to t=, and use the given symbols to label the necessary parts of the graph completely.e <stdio.h>
  3.  
  4. int main(void)
  5. {
  6. int i, j;
  7. long dec; /* ให้รับค่าอินพุทแบบ Long Integer - เลขจำนวนเต็มแบบยาว */
  8. int bit[32]; /* จองพื้นที่ในการเก็บข้อมูลเลขฐาน 2 ลงใน Array */
  9.  
  10. clrscr(); /* เคลียร์หน้าจอ */
  11. printf("Decimal Number : "); /* แจ้งผู้ใช้เพื่อเตรียมป้อนค่าเลขฐาน 10 */
  12. scanf("%ld", &dec); /* ต้องใช้ ld เพราะ Input มันเป็นแบบ Long Integer */
  13. i = 0; /* กำหนดค่าเริ่มต้นของ Array */
  14. /* ทำตามที่ได้ออกแบบโปรแกรมเอาไว้ ... ยังไงยังงั้นเลย 55555+ */
  15. do {
  16. bit[i++] = dec % 2; /* การหารเอาเศษ เพื่อให้เป็นคำตอบ */
  17.  
  18. /* การหารทั่วไป แต่ตัวแปร dec ของภาษา C มันเป็น Integer หรือ เลขจำนวนเต็ม */
  19. /* ดังนั้นมันจึงตัดเศษ (หรือทศนิยม) ทิ้งไปโดยอัตโนมัติ */
  20. dec = dec / 2;
  21.  
  22. } while (dec > 0); /* เงื่อนไขที่ทำจนกระทั่ง dec = 0 ก็ออกจากวังวนเงื่อนไข */
  23.  
  24. /* การแสดงผลของการแปลงเลขฐาน 10 เป็นเลขฐาน 2*/
  25. /* j = i - 1 และให้ j ลดค่าลงทีละ 1 ... ก็คืออ่านข้อมูลถอยหลังกลับเท่านั้นเองครับ */
  26. /* เพราะตัวแปรแบบ Array ในภาษา C มันเก็บข้อมูลจากซ้ายไปขวา */
  27. /* ทำให้ LSB มันไปอยู่ทางซ้าย ส่วน MSB มันไปอยู่ทางขวา */
  28. for(j = i - 1; j >= 0; j--)
  29. printf("%d", bit[j]);
  30.  
  31. printf("\n");
  32. return 0
  33.  
  34. }
Success #stdin #stdout 0.02s 25700KB
stdin
Standard input is empty
stdout
#includPlot a graph between temperature (T) and distance from the left edge of the sample material (x) from 0 to L for the sample material in equilibrium from the initial temperature to the final temperature, with the left and right ends of the sample material having the initial temperature T1 and T2 and the final temperature T1’ and T2’ respectively, along with the change of the graph with respect to
time from t=0 to t=∞, and use the given symbols to label the necessary parts of the graph completely.e <stdio.h>

int main(void)
{
int i, j;
long dec;  /* ให้รับค่าอินพุทแบบ Long Integer - เลขจำนวนเต็มแบบยาว */
int bit[32];  /* จองพื้นที่ในการเก็บข้อมูลเลขฐาน 2 ลงใน Array */

    clrscr();  /* เคลียร์หน้าจอ */
    printf("Decimal Number : ");  /* แจ้งผู้ใช้เพื่อเตรียมป้อนค่าเลขฐาน 10 */
    scanf("%ld", &dec);  /* ต้องใช้ ld เพราะ Input มันเป็นแบบ Long Integer */
    i = 0;  /* กำหนดค่าเริ่มต้นของ Array */
    /* ทำตามที่ได้ออกแบบโปรแกรมเอาไว้ ... ยังไงยังงั้นเลย 55555+ */
    do {
        bit[i++] = dec % 2;  /* การหารเอาเศษ เพื่อให้เป็นคำตอบ */

        /* การหารทั่วไป แต่ตัวแปร dec ของภาษา C มันเป็น Integer หรือ เลขจำนวนเต็ม */
        /* ดังนั้นมันจึงตัดเศษ (หรือทศนิยม) ทิ้งไปโดยอัตโนมัติ */
        dec = dec / 2;

    } while (dec > 0);  /* เงื่อนไขที่ทำจนกระทั่ง dec = 0 ก็ออกจากวังวนเงื่อนไข */

    /* การแสดงผลของการแปลงเลขฐาน 10 เป็นเลขฐาน 2*/
    /* j = i - 1 และให้ j ลดค่าลงทีละ 1 ... ก็คืออ่านข้อมูลถอยหลังกลับเท่านั้นเองครับ */
    /* เพราะตัวแปรแบบ Array ในภาษา C มันเก็บข้อมูลจากซ้ายไปขวา */
    /* ทำให้ LSB มันไปอยู่ทางซ้าย ส่วน MSB มันไปอยู่ทางขวา */
    for(j = i - 1; j >= 0; j--)
        printf("%d", bit[j]);

printf("\n");
return 0

}