Hi guys, I'm very very new to programming. Want to ask how to translate something like this for example: into C++code?
Statement: Do you want to reboot your device?
- Yes -No
Programming Newbie- I need help!
Programming Newbie- I need help!
|
Jan 22 2018, 10:02 PM, updated 7y ago
Show posts by this member only | Post
#1
|
Junior Member
136 posts Joined: Feb 2016 |
Hi guys, I'm very very new to programming. Want to ask how to translate something like this for example: into C++code?
Statement: Do you want to reboot your device? - Yes -No |
|
|
|
Jan 25 2018, 08:39 AM
Show posts by this member only | IPv6 | Post
#2
|
Junior Member
160 posts Joined: Nov 2008 |
you mean like this?
CODE #include <iostream> using namespace std; int main() { cout << "Statement: Do you want to reboot your device?" << endl; cout << "- Yes -No"; return 0; } or... something more elaborate like this... CODE #include <iostream> using namespace std; void rebootDevice(void) { // not implemented yet. throw std::runtime_error("not implemented yet."); } int main() { char ch = '\0'; cout << "Do you want to reboot your device?" << endl; cout << "1-Yes 2-No" << endl; cin >> ch; if (ch == '1') { try { rebootDevice(); } catch (std::exception &e) { cout << e.what() << endl; } } return 0; } |
|
Jan 25 2018, 10:15 AM
Show posts by this member only | Post
#3
|
Junior Member
136 posts Joined: Feb 2016 |
-REMOVED-
This post has been edited by C0deXeus: Jan 25 2018, 02:57 PM |
|
Jan 25 2018, 11:52 AM
Show posts by this member only | Post
#4
|
Junior Member
124 posts Joined: Feb 2012 |
just put "{}" e.g
CODE if (choice == 1) { cout<<"Earth with force of gravity of 1.00."<<endl; WeightE = weight*1.00; } but man, lain kali just ask straight forward question la... not something like 'how to reboot machine' - made me think you wanna do something naughty with your program |
|
Jan 25 2018, 02:54 PM
Show posts by this member only | Post
#5
|
Junior Member
136 posts Joined: Feb 2016 |
QUOTE(matsom @ Jan 25 2018, 11:52 AM) just put "{}" e.g Hahaha...I'm really sorry bout that, will not repeat the same mistake next time. The code works!! Thank you very much CODE if (choice == 1) { cout<<"Earth with force of gravity of 1.00."<<endl; WeightE = weight*1.00; } but man, lain kali just ask straight forward question la... not something like 'how to reboot machine' - made me think you wanna do something naughty with your program |
|
Jan 25 2018, 02:56 PM
Show posts by this member only | Post
#6
|
Junior Member
136 posts Joined: Feb 2016 |
-Code is removed-
Sorry for the inconvenience caused. This post has been edited by C0deXeus: Jan 25 2018, 03:22 PM |
Change to: | 0.0124sec
1.06
5 queries
GZIP Disabled
Time is now: 29th March 2024 - 03:14 PM |