언어/C언어 38

[C언어] for 반복문 / 무한 루프

for 반복문for(시작값; 끝값; 증가값)for(시작값; 조건문; 증가값)for(초기값; 조건식; 증가값)for(int i = 0; i for( ; ; ;) →무한 루프 발생  for 무한 루프#include int main(void) { int result_1 = testFor_1(); //return 0;}int testFor_1() { printf("----------- testFor_1 시작 -----------\n"); int num1, num2; for (; ;) { //무한루프 발생 printf("두 수를 입력(멈추려면 Ctrl + C) :"); scanf("%d %d", &num1, &num2); printf("%d + %d = %d\n", num1, num2, num1 + num..

언어/C언어 2025.03.03

[C언어] 3일차 통합본 / 220321

2025.02.09 - [C언어] - [C언어] 3일차 -1 할일 / if / switch / for / while / do ~ while [C언어] 3일차 -1 할일 / if / switch / for / while / do ~ while조건문ifswitch반복문forwhiledo ~ while if(조건문){참일 때 실행하는 구문} else {거짓일 때 실행하는 구문}antoroong.tistory.com    2025.02.09 - [C언어] - [C언어] 3일차 -2 if / printf() [C언어] 3일차 -2 if / printf()If printf() #include int main(void) { int test_if_result = testIf(); int test_if_result2 =..

언어/C언어 2025.02.10

[C언어] 3일차 -8 for 반복문 / 1부터 10까지 합구하기

for 반복문for(시작값; 끝값; 증가값)for(시작값; 조건문; 증가값)for(초기값; 조건식; 증가값)for(int i = 0; i for( ; ; ;) →무한 루프 발생  #include int main(void) {int test_for_1 = testFor(); return 0;}int testFor() { printf("----------- testFor 시작 -----------\n\n"); int i; for (int i = 0; i 0 ; j--) { printf("%d j 처음해보는 반복문 for \n", j); } printf("----------- testFor 종료 -----------\n\n"); return 0;}

언어/C언어 2025.02.10

[C언어] 3일차 -7 계산기/ switch

switch#include int main(void) {int test_switch_2 = testSwitch_2(); return 0;}int testSwitch_2() { printf("----------- testSwitch_2 시작 -----------\n\n"); int num1, num2; char ch; printf("첫번째 수를 입력 :"); scanf("%d", &num1); printf("연산자 입력 :"); scanf(" %c", &ch); printf("두번째 수를 입력 :"); scanf("%d", &num2); switch(ch) { case '+' : printf("%d + %d = %d 입니다 \n",num1, num2, num1+num2); break; case '-'..

언어/C언어 2025.02.10

[C언어] 3일차 -6 if / scanf 응용 / 계산기 만들기

if / scanf 응용/계산기 만들기 #include int main(void) {int test_scanf_2 = if_scanf_2(); return 0;}int if_scanf_2() { /* scanf() 첫 번째 정수를 입력해 주세요 : 10 계산할 연산자(+, -, *, /)를 입력해 주세요 : + 두 번째 정수를 입력해 주세요 : 8 10 + 8 = 18입니다. */ printf("----------- if_scanf_2 시작 -----------\n\n"); int num1, num2; char ch; printf("첫 번째 정수를 입력 :"); scanf("%d", &num1); printf("계산할 연산자를 입력 : "); scanf(" %c", &ch); //char이기때문에 %c앞..

언어/C언어 2025.02.10

[C언어] 3일차 -5 switch

switch와 caseif 와 else를 다른 방식으로 쓰는 것이다.#include int main(void) { int test_swich_1 = testSwitch(); return 0;}int testSwitch() { printf("----------- testSwitch 시작 -----------\n\n"); int a; printf("1~4중에서 하나를 선택하세요 :"); scanf("%d", &a); switch (a) { case 1 : printf("1번 선택했습니다\n"); break; //종료의 의미 이것이 없으면 다음 case도 실행됨 case 2 : printf("2번 선택하셨습니다\n"); break; case 3 : printf("3번 선택하셨습니다\n"); bre..

언어/C언어 2025.02.09

[C언어] 3일차 -4 if / 중첩 if문

중첩 if문if와 else if와 else if 등등  #include int main(void) {int test_if_result4 = testIf_4(); return 0;}int testIf_4() { printf("----------- testIf_4 종료 -----------\n\n"); int a; printf("정수를 입력해주세요 : "); scanf("%d", &a); if (a >= 90) { printf("A학점"); }else if(a >= 80) { printf("B학점"); } else if (a >= 70) { printf("C학점"); } else { printf("F학점"); } return 0; printf("----------- testIf_4 종료 -------..

언어/C언어 2025.02.09

[C언어] 3일차 -3 if / scanf() / 입력한 값이 홀수 인지 짝수인지 구하기

If scanf()#include int main(void) { int test_scanf_1 = testScanf(); return 0;}int testScanf() { printf("----------- testScanf 시작 -----------\n\n"); int a; printf("정수를 입력해 주세요"); scanf("%d", &a); if (a % 2 == 0) { //짝수일 경우 printf("짝수를 입력하셨군요"); } else { printf("홀수를 입력하셨군요"); } return 0; printf("----------- testScanf 종료 -----------\n\n");}

언어/C언어 2025.02.09