r/learnprogramming • u/Ancient-Plankton-908 • 25d ago
C Calculator
Hi there !
I made a simple calculator code, its my first project !
i learn a good things like how to use switch , printf(""); and scanf("");
I did not use any AI on it
It solve those op :
- Addition (
+) - Subtraction (
-) - Multiplication (
*) - Division (
/)
Some features:
- Handle division by zero
- Support decimal numbers
I use VS code
Thanks and what do you suggest next <3
The code in github: [https://github.com/UseR-Name-Dz/Calculator-]
12
Upvotes
2
u/abd53 25d ago
Try evaluating expressions next. For example, 3+2(5-6/2)
1
u/Flame77ofc 25d ago
Is it on GitHub?
1
u/Juukamen 25d ago
Awsome start mate.
As the others are saying, exand functions and make a GUI.
1
u/lehrerkind_ 25d ago
Did you forget to post the link to your code of did you just want to share that you have done something without sharing the code?
1
u/Dazzling_Music_2411 25d ago edited 25d ago
Make it behave more naturally.
Save the last result automatically. This will actually make it usable!
For instance if I type "2 + 3 =" it should return 5. If I then type "x 7" it should show "Ans x 7" and when I press "=" it should show "35".
I think that's how real modern calculators work.
Later, if you want to have a proper challenge, you can try larger expressions, e.g.
3 * (2 - 5) + 7 / 9but his will require learning some "real" programming, including possibly the use of the bison parser, or similar. That is the real world of C. 😄1
u/Agawell 25d ago
Add a gui - buttons and a screen
Add scientific function
Add graphing tool
1
u/Key_River7180 25d ago
great!!!
1
u/cheezballs 25d ago
Heck yea! Writing a calculator is also a really great introduction to Stack data structures (a more advanced topic when you get there)
I also had an assignment in school to implement stop-lights at an intersection, which is another pretty easy but pretty fun thing to do.
1
u/w8tA 19d ago
The goat my friend
0
u/[deleted] 25d ago
[removed] — view removed comment