자유게시판

아직도 고1때 작성한 소스파일이 남아있었을 줄이야....................ㅋㅁㅋ;;
옛날 기억이 새록새록~>ㅁ<
( 고1때 직접 작성한 것이기에, 영어 오타나 오기[誤記]가 있을지도 모릅니다;; )



// Program 2 : Read(Input) values and Calculate Average
// sentinel value is -1
#include <stdio.h>

// function main begins program execution
int main ( void ) {
// define variables
int i; // input count
int value;
int sum;
float average; // average is floating-point number

// initialize
i = 0 ;
sum = 0 ;

// program introduction
printf("*******************************************************************************\n");
printf("Program Introduction\n");
printf("*******************************************************************************\n");
printf("This program calculate integers average.\n");
printf("Do not enter zero or negative value. (Use only positive integer.)\n");
printf("If you enter value for -1, the input phase is end\n");
printf("and result(average) will be come out.\n");
printf("*******************************************************************************\n\n");

// first read value
printf("Input Value : ");
scanf("%d", &value);

// sentinel value is -1 >>> if value is -1, end input 
// error case 1 >>> if value is -1 and i is 0, print error message 1
// error case 2 >>> if value is not legitimate (zero or negative except -1), print error message 2
while ( value >= 0 ) {
sum += value ; // add value to sum
++i ; // increment count

// next read value
printf("Input Value : ");
scanf("%d", &value);
} // end while

/********************************* termination conduct *********************************/

/***** error case 1 *****/
if ( ( value == -1 ) && ( i == 0 ) ) { 
printf("\n[ERROR 1] You didn't input value\n"); // print error message 1
} // end if

/***** error case 2 *****/
else if ( value != -1 ) { 
printf("\n[ERROR 2] Input Error - Don't input negative or zero\n"); // print error message 2
} // end else if

/***** no error *****/
else { 
// calculate average
average = (float)sum / i ;

// print result(average) - precision is .2
printf("\nAverage is %.2f\n\n", average);
} // end else

return 0; // terminate program successfully
}

Who's 미루

?

< 제작한 게임 >

- 피그렛 (Piglet) [완성] : 링크 내림

- 파라딜루전 (Paradelusion) [미완성] : 링크 내림

- 주인잃은 공책 [완성] : http://avangs.info/1090264


< 연구실 홈페이지 >

http://mirulab.xo.st/


< 아방스 게임 실황 방송국 >

http://afreeca.com/miru3137

Comment '4'
  • ?
    TheEK 2013.02.02 20:40
    저에겐 그저 머~~~언 안드로메다 ... ㅠ
  • ?
    미루 2013.02.02 20:52
    안드로메다- ㅋㅁㅋ;;
  • profile
    하늘바라KSND 2013.02.02 21:48
    평균계산기?!
  • ?
    미루 2013.02.02 22:19
    넵~ 양의정수(자연수)들의 평균을 계산하는 매우 기초적인 프로그래밍입니다~ ㅎㅎ;;

  1. 아방스 게시물 · 댓글 작성 규칙 (최근 수정일 2015.11.25)

    Date2012.07.17 Category공지 By완폐남™ Views40605
    read more
  2. CD룸 없을때 CD에 있는거 설치하기

    Date2013.02.24 By황금시계 Views1626
    Read More
  3. CCL 관련 글인것 같은데

    Date2011.07.24 By하늘바라KSND Views874
    Read More
  4. c9이라....

    Date2009.08.19 Category잡담 By아비 Views1056
    Read More
  5. c&c 제너럴 - 제로아워

    Date2009.04.18 Category잡담 By君塚ちえい Views624
    Read More
  6. C#용으로 조사처리 라이브러리 한번 만들어봤습니다.

    Date2014.07.28 Category잡담 By맛난호빵 Views815
    Read More
  7. C 프로그래밍 초보자였을 때 작성한 소스파일

    Date2013.02.02 Category잡담 By미루 Views1092
    Read More
  8. c o m to the p u t e r

    Date2010.06.06 Category잡담 By코르뉴 Views278
    Read More
  9. B군과 천도와 같은 존재

    Date2010.04.27 Category잡담 By강현문 Views378
    Read More
  10. Boy♂와 소방차 게임 음성더빙 [ 유튜브 ]

    Date2013.12.25 Category막장 By스리아씨 Views970
    Read More
  11. Border of dimension ~ 시공의 틈 제작 현황

    Date2011.01.06 Category제작 영상 By맛난호빵 Views552
    Read More
  12. bms제작..

    Date2009.07.21 Category잡담 ByCiTY Views978
    Read More
  13. bj 대도서관 10월 수입 3500만

    Date2013.12.24 Category잡담 By파치리스 Views1023
    Read More
  14. BIC 연사 모집한다고 하는데 기획자 분들은 좋은 기회일 것 같네요

    Date2022.07.06 Category잡담 By빵야빵야 Views341
    Read More
  15. BGM을 어디서 구하는게 좋을까요

    Date2014.01.22 Category잡담 By이룩 Views504
    Read More
  16. Bgm 저작권 표시

    Date2017.05.30 Category설문 ByKYJoon Views203
    Read More
  17. BGM 작업물들 평가좀 부탁드립니다 !

    Date2015.09.20 Category발표 By7thcloud Views65
    Read More
  18. Bar Mortis - 1. 쯔꾸르는 기획서가 없어도 어떻게든 된다고 생각하는 사람을 조심하라

    Date2021.07.01 Category제작 일지 By매듭이 Views141
    Read More
  19. B-36 도트 제작중

    Date2012.01.25 Category제작 스샷 By으니찡 Views2436
    Read More
  20. a폐드립 최강

    Date2011.01.25 Category막장 By위너프리드● Views409
    Read More
  21. Aㅏ ... 노가다 ...

    Date2013.07.02 ByTheEK Views559
    Read More
목록
Board Pagination Prev 1 ... 718 719 720 721 722 723 724 725 726 727 728 729 730 731 732 733 734 735 736 737 ... 755 Next
/ 755