#include <iostream>
using namespace std;
int main()
{
int res;
count << "정수를 입력해주세요. \n"
cin >> res;
if (res == 1){
cout << "1이 입력되었습니다.";
}
else {
cout << "1이 아닌 값이 입력되었습니다. \n";
}
return 0;
}
// python
// num = int(input())
// if num:
// print("1이 입력되었습니다.")
// else:
// print("1이 아닌 값이 입력되었습니다.")
반복문 - for 문
#include <iostream>
using namespace std;
int main()
{
for(int i=1; i<6; i++ {
cout << i << "입니다. \n";
}
cout << "출력 끝!\n";
return 0
}
// python
// for i in range(1, 6, 1):
// print(f"{i}입니다.")
반복문 - while 문
#include <iostream>
using namespace std;
int main()
{
int i = 1;
while(i<6){
cout << i << "입니다. \n";
i++;
}
cout << "출력 끝!\n";
return 0
}
// python
// i = 1
// while i < 6:
// print(f"{i}입니다.")
// i += 1