code
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51
| #include <stdio.h> #include <stdlib.h> #include <windows.h>
int main(void) { system("title 모든 수 합해주는 PG"); SetConsoleTextAttribute( GetStdHandle( STD_OUTPUT_HANDLE ), 3); long a,input, sum = 0; char input_1; printf("+-----------------------------------+\n"); printf("- -\n"); printf("- EX) 1+2+3 ... +10 = 55 -\n"); printf("- -\n"); printf("- 10개를 더할려면 10을 입력하세요. -\n"); printf("+-----------------------------------+\n"); printf(" \n\n\n\n총 몇개의 수를 더해줄 건가요 : "); scanf("%ld", &input); for(a=0; a<=input; a++) sum += a; printf("\n\n\n"); printf("+=====================================================+\n"); printf("- -\n"); printf("- %ld의 모든 수를 더한 값은: '%ld'입니다. -\n",input,sum); printf("- (반복하실려면 'b'를 종료하실려면 'q'를 입력하세요.) -\n"); printf("+=====================================================+\n"); printf("반복 하시겠습니까, 종료 하시겠습니까: "); scanf("%s", &input_1); if(input_1 == 'b') { return main(); } if(input_1 == 'q') { return 0; } }
|
Author:
Slay
Permalink:
http://sean-baek.github.io/2022/08/21/2022-08-21-sum-all-entered-numbers-function/
License:
Copyright (c) 2021 CC-BY-NC-4.0 LICENSE
Slogan:
Do you believe in DESTINY?