Welcome Guest ( Log In | Register )

Outline · [ Standard ] · Linear+

 Programming Newbie- I need help!

views
     
TSC0deXeus
post Jan 22 2018, 10:02 PM, updated 7y ago

Getting Started
**
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
RookieDaddy
post Jan 25 2018, 08:39 AM

Getting Started
**
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;
}

TSC0deXeus
post Jan 25 2018, 10:15 AM

Getting Started
**
Junior Member
136 posts

Joined: Feb 2016
-REMOVED-

This post has been edited by C0deXeus: Jan 25 2018, 02:57 PM
matsom
post Jan 25 2018, 11:52 AM

Getting Started
**
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 sweat.gif
TSC0deXeus
post Jan 25 2018, 02:54 PM

Getting Started
**
Junior Member
136 posts

Joined: Feb 2016
QUOTE(matsom @ Jan 25 2018, 11:52 AM)
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 sweat.gif
*
Hahaha...I'm really sorry bout that, will not repeat the same mistake next time. The code works!! Thank you very much icon_idea.gif
TSC0deXeus
post Jan 25 2018, 02:56 PM

Getting Started
**
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:
| Lo-Fi Version
0.0124sec    1.06    5 queries    GZIP Disabled
Time is now: 29th March 2024 - 03:14 PM