Forum

> > Off Topic > My first start in c++ (Calculator).
Forums overviewOff Topic overviewLog in to reply

English My first start in c++ (Calculator).

14 replies
To the start Previous 1 Next To the start

old closed My first start in c++ (Calculator).

script favor
User Off Offline

Quote
I created a small calculator please don't cringe , i will continue :

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
#include <iostream>
#include <fstream>
#include <conio.h>
using namespace std;



int main()
{
int n;
int n2;
char op;

string text = "Please enter numbers to begin to calculate";

cout << text;
cin >> n >> op >> n2;

int result;
if(op == '+') {

    result = n + n2;


}else if(op == '-') {

    result = n - n2;

}else if(op == '*') {

    result = n * n2;

}else if(op == '^'){

    result = n ^ n2;

}
  cout << result;
   return result;
}
edited 2×, last 11.03.19 08:15:16 pm

old Re: My first start in c++ (Calculator).

Rainoth
Moderator Off Offline

Quote
You shouldn't post stuff like that if it's not anything impressive. Unless you don't understand how something works in which case maybe you could.

Nobody makes a thread every time they manage to print out "Hello World" in cs2d with lua scripting (or in any other language for that matter). Even if it feels fucking awesome

old Re: My first start in c++ (Calculator).

ohaz
User Off Offline

Quote
A few hints that will make coding a lot easier / better in the future:

• Use the indentations. Correctly. Focus on that. It's super important
• Give your variables good names. "n" and "n2" are not good names. "op" is also not a good name.
• Don't return the result, the return value of the main function is the exit code of the application and a return value != 0 is usually considered to be an error.

other than that: congratulations on writing your first lines of code! Continue training!

old Re: My first start in c++ (Calculator).

_oops
User Off Offline

Quote
First programming, first is always exciting and want to brag it to people even though that is basic stuff.

Well done and never forget that feeling, continue your programming.
But, ya don't brag every time whenever you program something basic. cheers fella

old Re: My first start in c++ (Calculator).

Rainoth
Moderator Off Offline

Quote
@user tek69 & @user script favor: Off-topic does not mean "anything useless with no significance" by the way. I'd pass it down if you were asking for help but unfortunately that is not the case here.
I'm not trying to be the bad guy here and ruin your fun. Just have some common sense.
@user tek69: You should consider contributing something meaningful if you think it's "nothing but a trash collection" or alternatively if you don't want to do that, you may leave

old Re: My first start in c++ (Calculator).

tek69
User Off Offline

Quote
@user Rainoth:
Well, I am not the one who said this thread is useless, "meaningful" is not a word for individual, not from you. Either way you can ban us all or close this thread, your comments are useless that's what I am saying, in case you don't understand.

old Re: My first start in c++ (Calculator).

Mami Tomoe
User Playing CS2D

Quote
This thread is hella spicy, what's with all the negativity?
Y'all need to chill or something.

Anyways this thread isn't useful or useless, it's a good way to motivate people to become programmers but that isn't very likely.

I think this thread should stay as long as people stop going off topic.

old Re: My first start in c++ (Calculator).

Rainoth
Moderator Off Offline

Quote
@user tek69:
I shall explain one last time then.
You said the forum is nothing but a trash collection, a useless forum.
I disagree with that statement but the only thing I can do now is to repeat myself and ask you to either contribute something so that it's no longer useless (to you) or leave, because coming in and saying "this forum is useless" is meaningless. If you critique something, suggest solutions. Whining for the sake of whining isn't helping anyone.
If I interpret this correctly, you saying "'meaningful' is not a word for individual, not from you" means you thing what I do is not meaningful. That's fine, one or two voices isn't a significant part of this community.
So to put it simply for you to understand:
If you post meaningless things, that's wrong (it's obvious why that is so).
If I (or any other person for that matter) comes and calls you out on it and explains what you could do instead (like I did before, for instance), that's not a meaningless thing. If that makes you realize that you have better things to do with your life than complain about the forum, more power to the person who called you out on it.
To keep this reply shorter (since it's already becoming a wall of text), I'm mostly aiming it at what user tek69 said instead of both of you.

I think user script favor got enough encouragement to keep practicing programming and enough negative responses to understand not to do this again.
Closed.
To the start Previous 1 Next To the start
Log in to replyOff Topic overviewForums overview