C++ Programming Ch.2 Exercise 2 Solution

Problem: cout과 << 연산자를 이용하여 다음과 같이 구구단을 출력하는 프로그램을 작성하라. Objective & Hints: cout 활용, 화면 출력 Execution Result: Code: 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 #include using namespace std; int main() { int i, j; for(i=1; i<10; i++){ for(j=1; j<10; j++) { cout << j << "x" << i << "=" << j*i << '\t'; if(j==9) // 9단 출력 후 줄바꿈. cout << endl; } } return 0; } Explanation: ...

February 28, 2020 · 1 min · Sobamemil

C++ Programming Ch.2 Exercise 1 Solution

Problem: cout과 << 연산자를 이용하여, 1에서 100까지 정수를 다음과 같이 한 줄에 10개씩 출력하라. 각 정수는 탭으로 분리하여 출력하라. Execution Result: Objective & Hints: cout 활용, 화면 출력 Code: 1 2 3 4 5 6 7 8 9 10 11 12 13 14 #include using namespace std; int main(){ int i; for(i=1;i<101;i++){ cout << i << "\t"; if(i%10==0) // 10개마다 개행문자 출력 cout << endl; } return 0; } Explanation: ...

February 28, 2020 · 1 min · Sobamemil