Notice
Recent Posts
Recent Comments
Link
«   2025/09   »
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
Tags
more
Archives
Today
Total
관리 메뉴

이것저것

C언어 swea 2027 N줄 덧셈 본문

Language/C언어

C언어 swea 2027 N줄 덧셈

olivia-com 2020. 11. 20. 09:59

https://swexpertacademy.com/main/identity/anonymous/loginPage.do

 

SW Expert Academy

SW 프로그래밍 역량 강화에 도움이 되는 다양한 학습 컨텐츠를 확인하세요!

swexpertacademy.com

#include <stdio.h>

int get_sum(void); //함수 선언 

int main(void)
{
	int result; //변수 result 선언 
	
	result = get_sum(); //함수 호출하고 반환값은 result에 저장 
	printf("\n%d", result); //반환값 출력 
	return 0;
}

int get_sum(void)
{
	int count,num,i; //변수 count,num,i 선언 
	scanf("%d", &num); //입력받은 수를 변수 num에 저장 
	for(i=1; i<=num; i++) //for문 사용 
	{
		count += i; //1부터 num까지 count에 계속 더함 
	}
	return count; //count값 반환 
}

'Language > C언어' 카테고리의 다른 글

C언어 swea 2047 신문 헤드라인  (0) 2020.11.20
C언어 swea 2025 대각선 출력하기  (0) 2020.11.20
C언어 swea 2043  (0) 2020.11.20
C언어 swea 1936  (0) 2020.11.20
C언어 swea 2029  (0) 2020.11.20