Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
Download

CSC112 Spring 2016 Examples

2368 views
1
#include <iostream>
2
3
using namespace std;
4
5
int oddify(int x) {
6
if(x%2 == 0) {
7
return x-1;
8
}
9
10
throw "Problem!";
11
}
12
13
int main()
14
{
15
int x;
16
17
cout << "Enter an integer: ";
18
cin >> x;
19
20
x=oddify(x);
21
22
cout << "The odd version of your number is: " << x << endl;
23
24
return 0;
25
}
26