#include <iostream>using namespace std;int main(){ int n; cin >> n; if(n % 2 == 0) cout << n << endl; else cout << n * 2 << endl; return 0;}
Question
#include <iostream>using namespace std;int main(){ int n; cin >> n; if(n % 2 == 0) cout << n << endl; else cout << n * 2 << endl; return 0;}
🧐 Not the exact question you are looking for?Go ask a question
Solution
This is a simple C++ program that reads an integer from the user, checks if it's even or odd, and then prints the number itself if it's even, or twice the number if it's odd.
Here's a step-by-step explanation:
#include <iostream>: This line includes the iostream library,
Similar Questions
0/0
Upgrade your grade with Knowee
Get personalized homework help. Review tough concepts in more detail, or go deeper into your topic by exploring other relevant questions.