Created
October 28, 2021 00:56
-
-
Save VisualAcademy/16d8f7a03719eee94a8e70def62457d7 to your computer and use it in GitHub Desktop.
C 언어 1부터 100까지 짝수의 합을 구하는 프로그램
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//[?] 1부터 100까지 짝수의 합을 구하는 프로그램 | |
#include <stdio.h> | |
int main(void) | |
{ | |
//[1] Input(입력) | |
int sum = 0; | |
//[2] Process(처리) : 주어진 범위(for 문)에 주어진 조건(if 문) | |
for (int i = 1; i <= 100; i++) // 1부터 100까지 범위 지정 | |
{ | |
if (i % 2 == 0) // 짝수만 필터링(조회) | |
{ | |
sum += i; // 짝수일 때만 합 구하기 | |
} | |
} | |
//[3] Output(출력) | |
printf("1부터 100까지 짝수의 합: %d\n", sum); | |
return 0; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment