본문 바로가기
Coding/C언어 - Codeup

[코드업/Codeup][C언어] 1107 ~ 1108 반복 출력 문제 풀이

by 이브(Eve) 2024. 8. 31.

# 1106 : 반복 출력하기 1

print 단어를 연속으로 50번 출력하시오.(띄어쓰기 없음)

#include <stdio.h>

int main()
{
	for (int i = 0; i < 50; i++) printf("print");

	return 0;
}

 

반복문을 사용하여 해결합니다.


# 1107 : 반복 출력하기 2

hello를 20번 연속출력한 다음 한 칸을 띄우고(공백 한칸(줄바꿈 아님)) world를 연속 30번 출력하시오.

#include <stdio.h>

int main()
{
	for (int i = 0; i < 20; i++) printf("hello");
	printf(" ");
	for (int i = 0; i < 30; i++) printf("world");

	return 0;
}