자유게시판

아직도 고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 41184
잡담 이프/봉시기/펜굴림이님보세요. 1 수라 2009.10.02 1089
잡담 주소 도대채 언제바낀거야? 3 ㅇㅇㅇㅇ 2008.01.28 1090
잡담 주인공컨셉 file 잉여VICTIM 2011.10.11 1090
잡담 넷에 돌아다니는 소위 말하는 'RPG 만들기 VX Ace 영어판 크랙'이라는 것들... Alkaid 2012.09.07 1090
잡담 괴도키드의 나들이 클로즈 베타테스터 모집 2 괴도키드 2009.07.27 1091
잡담 용호작무님 바보 20 루넨스 2010.01.11 1091
잡담 전 코드브레이커를 추천합니다 file Luxmea 2011.05.04 1091
잡담 이제 곧 병장이네요... 2 코르뉴 2013.01.05 1091
잡담 환경설정도 완성. 파죽지세. 3 Evangelista 2009.09.20 1092
잡담 musyc이라는 작곡앱 4 yellowcat 2013.06.03 1092
잡담 rpg 만들기 모험... 5 히키모리 2008.02.27 1093
잡담 지속적으로 업데이트중 6 아이미르 2012.03.08 1093
잡담 바니걸 세이버 완성 +_+..? 17 봉시기 2009.10.27 1094
잡담 여기서 백날 욕해봐야 톱키노슨상님 신경도 안씁니다 4 Evangelista 2011.04.13 1094
잡담 괴도키드님, 주문하신 이미지 닉네임 완료! 1 칼리아 2009.08.23 1095
잡담 이번에 수능 본 횽들 있음? 2 Evangelista 2009.11.24 1095
잡담 C 프로그래밍 초보자였을 때 작성한 소스파일 4 미루 2013.02.02 1095
잡담 이렇게나옴 4 라이네크 2009.09.04 1096
잡담 져때씀 ㅡ.ㅡ; 2 Evangelista 2009.09.12 1097
잡담 마인크래프트에서 삭제된 몹 중 하나. Alkaid 2011.02.09 1097
목록
Board Pagination Prev 1 ... 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 ... 456 Next
/ 456