MUstar

IoT C언어 0508 - 8-2

May 8th, 2017
64
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. #include <stdio.h>
  2.  
  3. int main(void)
  4. {
  5.     // 배열선언 및 초기화
  6.     int txt1[5] = {1,2,3,4,5};
  7.     int txt2[5] = {1,2,3};
  8.     int txt3[] = {1,2,3};
  9.     double txt4[5] = {1.0,2.1,3.2,4.3,5.4};
  10.     char txt5[5] = {'a','p','p','l','e'};
  11.     int txt6[1];
  12.    
  13.     // txt1의 각각배열에 대입값.
  14.     txt1[0] = 10;
  15.     txt1[1] = 20;
  16.     txt1[2] = 30;
  17.     txt1[3] = 40;
  18.     txt1[4] = 50;
  19.  
  20.     //txt6 값입력
  21.     printf("txt6 값입력 : ");
  22.     scanf("%d", &txt6[0]);
  23.    
  24.     //txt1출력
  25.     printf("-txt1\n");
  26.     printf("%d\n",txt1[0]);
  27.     printf("%d\n",txt1[1]);
  28.     printf("%d\n",txt1[2]);
  29.     printf("%d\n",txt1[3]);
  30.     printf("%d\n",txt1[4]);
  31.     //txt2출력
  32.     printf("-txt2\n");
  33.     printf("%d\n",txt2[0]);
  34.     printf("%d\n",txt2[1]);
  35.     printf("%d\n",txt2[2]);
  36.     printf("%d\n",txt2[3]);
  37.     printf("%d\n",txt2[4]);
  38.     //txt3출력
  39.     printf("-txt3\n");
  40.     printf("%d\n",txt3[0]);
  41.     printf("%d\n",txt3[1]);
  42.     printf("%d\n",txt3[2]);
  43.     printf("%d\n",txt3[3]);
  44.     printf("%d\n",txt3[4]);
  45.     //txt4출력
  46.     printf("-txt4\n");
  47.     printf("%lf\n",txt4[0]);
  48.     printf("%lf\n",txt4[1]);
  49.     printf("%lf\n",txt4[2]);
  50.     printf("%lf\n",txt4[3]);
  51.     printf("%lf\n",txt4[4]);
  52.     //txt5출력
  53.     printf("-txt5\n");
  54.     printf("%s\n",txt5);
  55.     //txt6출력
  56.     printf("-txt6\n");
  57.     printf("%d\n",txt6[0]+10); //배열의 값에 10을 더해 출력
  58.    
  59.     return 0;
  60. }
RAW Paste Data