자유게시판

아직도 고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
    넵~ 양의정수(자연수)들의 평균을 계산하는 매우 기초적인 프로그래밍입니다~ ㅎㅎ;;

List of Articles
분류 제목 글쓴이 날짜 조회 수
공지 아방스 게시물 · 댓글 작성 규칙 (최근 수정일 2015.11.25) 17 file 완폐남™ 2012.07.17 41177
잡담 헐 회원탈퇴 엄청 쉽게되네... 4 파치리스 2013.03.09 1230
헐.. 그저안습이네;; 2 vx가좋나xp가좋나 2010.05.26 441
잡담 헐... 강좌 어려워.... 6 『【동그라미】』 2010.05.02 387
잡담 헐... 어디서 이런 오류가... Jenpia 2010.07.17 303
잡담 헐.... 2 아르피쥐 2011.12.09 1408
헐.... 이건 신세대 병 TO THE 신이다...;; 12 J H L 2010.04.19 464
제작 스샷 헐........ 난이도가......... 'Piglet(피그렛) 베타(β)구역' 17 file 미루 2013.02.20 1104
잡담 헐.....? 2 JEWAPPI 2010.07.25 236
잡담 헐...메탈기어솔리드 ㄷㄷㄷㄷ 3 file JACKY 2012.10.27 974
잡담 헐;;순간적인 에러인건가;; 5 질풍처럼 2011.01.25 295
잡담 헐~ 몰랐었는데 어제 제블로그 오던 떴었군요 ㅡㅡ;;; 7 아방스 2010.06.28 330
헐~~ 은색바람 2011.10.30 1087
잡담 헐ㅋ 나 프로그램 몇개쓰는거...ㅋㅋ 7 JEWAPPI 2010.07.20 715
잡담 헐ㅋ.. 2 레인폴스 2010.03.06 590
잡담 헐리웃 공포영화 bgm별 쓸모도없네요. Rimarks 2009.07.30 1679
헐으아니으아니 씨유 노래 최강자리 예약을 한 노래가 떳네요 하늘바라KSND 2011.12.07 1230
잡담 헐퀴 99점???? 4 늑당 2009.05.11 556
잡담 헐헐헐 진짜 쩔게 큰 검이다. 10 file 엘리카 2011.05.07 908
제작 일지 험난하군요 2 프리뮬러 2014.12.14 201
잡담 험블 스토어에서 rpg maker mv 할인하는데 여기서 사면 한글 적용이 되있을까요? 6 두부냠냠 2017.08.10 145
목록
Board Pagination Prev 1 ... 722 723 724 725 726 727 728 729 730 731 732 733 734 735 736 737 738 739 740 741 ... 755 Next
/ 755