# decimals in calculator

This is a discussion on decimals in calculator within the C++ Programming forums, part of the General Programming Boards category; how do you put them in Code: #include <iostream> #include <stdio.h> #include <string.h> #include <ctype.h> #include <math.h> #include <conio.h> #include ...

1. ## decimals in calculator

how do you put them in

Code:
```#include <iostream>
#include <stdio.h>
#include <string.h>
#include <ctype.h>
#include <math.h>
#include <conio.h>
#include "global.h"

double sqrt(double x);

using namespace std;

void vermenigvuldigen ();
void optellen  ();
void aftrekken () ;
void delen ();
void vierkantswortel ();
void credits ();

void setcolor(unsigned short color) {	//begining of set color funtion
HANDLE hCon = GetStdHandle(STD_OUTPUT_HANDLE);  	//gets std handle
SetConsoleTextAttribute(hCon,color);
}
int main (void)
{
C.I = 4;
setcolor(C.I);

cout << " ______   _______   _        ______      \n";
cout << "|  ____| |  ___  | | |      |  ____|  \n";
cout << "| |      |  | |  | | |      | |      \n";
cout << "| |____  |  ---  | | |____  | |____ \n";
cout << "|______| |__| |__| |______| |______| v0.041 Beta \n";
int input;
C.I = 6;
setcolor(C.I);
cout<<"1. Vermenigvuldig\n";
cout<<"2. delen\n";
cout<<"3. optellen\n";
cout<<"4. aftrekken\n";
cout<<"6. Vierkantswortel\n";
cout<<"7. Credits , historie en To-Do\n";
cout<<"8. sluiten\n";
C.I = 7;
setcolor(C.I);
cout<<"selecteer:";
cin>> input;
switch (input) {
case 1:
system("cls");

vermenigvuldigen();

case 2 :
system("cls");
delen();
case 3 :
system("cls");
optellen();
case 4 :
system("cls");
aftrekken();
case 5 :
system("cls");
case 6 :
system("cls");
vierkantswortel();
case 7 :
system("cls");
credits();

case 8 :
system("cls");
exit ( EXIT_FAILURE );//sluit af
default:
system("cls");
cout<<"error , slechte selectie , probeer opnieuw\n";
main();
cin.get();
}

}

inline void vermenigvuldigen()
{
float hello1;

int x;
int y;
C.I = 8;
setcolor(C.I);

cout<<"schrijf 2 getallen voor te vermenigvuldigen: ";
cin>>x>>y;
cin.ignore();
cout<<"het produkt van de 2 getallen is ";
C.I = 10;
setcolor(C.I);
cout<<x*y<<"\n";
int input;
C.I = 4;
setcolor(C.I);
cout<<"1.nog eens\n";
cout<<"3.sluiten\n";
cout<<"selectie";
cin>>input;
switch (input) {
case 1:
system("cls");
vermenigvuldigen();
case 2 :
system("cls");
main();
case 3 :
system("cls");
exit ( EXIT_FAILURE );//sluit af
default:
system("cls");
cout<<"error , slechte selectie , probeer opnieuw\n";
vermenigvuldigen();
}
}
inline void optellen ()
{
int x;
int y;
C.I = 8;
setcolor(C.I);
cout<<"schrijf 2 getallen om optetellen: ";
cin>>x>>y;
cin.ignore();
cout<<"de som van de 2 getallen is ";
C.I = 10;
setcolor(C.I);
cout<<x+y<<"\n\n\n\n";
int input;
C.I = 4;
setcolor(C.I);
cout<<"1.nog eens\n";
cout<<"3.sluiten\n";
cout<<"selectie";
cin>>input;
switch (input) {
case 1:
system("cls");
optellen();
case 2 :
system("cls");
main();
case 3 :
system("cls");
exit ( EXIT_FAILURE );//sluit af
default:
system("cls");
cout<<"error , slechte selectie , probeer opnieuw\n";
optellen();
}
}
inline void delen ()
{
int x;
int y;
C.I = 8;
setcolor(C.I);
cout<<"schrijf 2 getallen om te delen: ";
cin>>x>>y;
cin.ignore();
cout<<"het quotient van de 2 getallen is ";
C.I = 10;
setcolor(C.I);
cout<<x/y<<"\n\n\n\n";
int input;
C.I = 4;
setcolor(C.I);
cout<<"1.nog eens\n";
cout<<"3.sluiten\n";
cout<<"selectie";
cin>>input;
switch (input) {
case 1:
system("cls");
delen();
case 2 :
system("cls");
main();
case 3 :
system("cls");
exit ( EXIT_FAILURE );//sluit af
default:
system("cls");
cout<<"error , slechte selectie , probeer opnieuw\n";
delen();
}
}
inline void aftrekken ()
{
int x;
int y;
C.I = 8;
setcolor(C.I);
cout<<"schrijf 2 getallen om aftetrekken: ";
cin>>x>>y;
cin.ignore();
cout<<"het verschil van de 2 getallen is ";
C.I = 10;
setcolor(C.I);
cout<<x-y<<"\n\n\n\n";
int input;
C.I = 4;
setcolor(C.I);
cout<<"1.nog eens\n";
cout<<"3.sluiten\n";
cout<<"selectie";
cin>>input;
switch (input) {
case 1:
system("cls");
aftrekken();
case 2 :
system("cls");
main();
case 3 :
system("cls");
exit ( EXIT_FAILURE );//sluit af
default:
system("cls");
cout<<"error , slechte selectie , probeer opnieuw\n";
aftrekken();
}
}
{
int x;

C.I = 8;
setcolor(C.I);
cout<<"schrijf een getal om te kwadrateren: ";
cin>>x;
cin.ignore();
cout<<"het kwadraat van het getal is ";
C.I = 10;
setcolor(C.I);
cout<<x*x<<"\n\n\n\n";
int input;
C.I = 4;
setcolor(C.I);
cout<<"1.nog eens\n";
cout<<"3.sluiten\n";
cout<<"selectie";
cin>>input;
switch (input) {
case 1:
system("cls");
case 2 :
system("cls");
main();
case 3 :
system("cls");
exit ( EXIT_FAILURE );//sluit af
default:
system("cls");
cout<<"error , slechte selectie , probeer opnieuw\n";
}
}
inline void vierkantswortel ()
{
int x;

C.I = 8;
setcolor(C.I);
cout<<"schrijf een getal om de vierkantswortel van te berekenen: ";
cin>>x;
cin.ignore();
cout<<"de vierkantswortel van het getal is ";
C.I = 10;
setcolor(C.I);
cout<<sqrt (x)<<"\n\n\n\n";
int input;
C.I = 4;
setcolor(C.I);
cout<<"1.nog eens\n";
cout<<"3.sluiten\n";
cout<<"selectie";
cin>>input;
switch (input) {
case 1:
system("cls");
vierkantswortel();
case 2 :
system("cls");
main();
case 3 :
system("cls");
exit ( EXIT_FAILURE );//sluit af
default:
system("cls");
cout<<"error , slechte selectie , probeer opnieuw\n";
vierkantswortel();
}

}
inline void credits ()
{
C.I = 8;
setcolor(C.I);
cout<<"                              A -=[RP]=- Production\n";
cout<<"                                 Coded by Roel  \n\n\n";
C.I = 7;
setcolor(C.I);
cout<<"Historie: \n";
cout<<"v0.01 : verminigvuldigen test\n";
cout<<"v0.02 andere bewerkingen erbijgevoegd na succesvolle test\n";
cout<<"v0.03 menu toegevoegd ,waardoor niet alle bewerking worden uitgevoerd in 1 keer\n";
cout<<"v0.031 : irritante sluit-bug gefixt\n";
cout<<"v0.04 : text kleuren ingevoegd\n";
C.I = 6;
setcolor(C.I);
cout<<"To Do : \n";
cout<<"v0.05 : komma getallen invoegen\n";
cout<<"v0.06 : lay-out\n";
cout<<"....\n";
cout<<"v1.0 : port naar psp met ingebouwd toetsenbord\n\n\n";
int input;
C.I = 5;
setcolor(C.I);
cout<<"1. Ga terug\n";
cout<<"2. sluiten\n";
cout<<"selectie:";
cin>> input;
switch (input) {
case 1:
system("cls");
main();
case 2:
system("cls");
exit ( EXIT_FAILURE );//sluit af

default:
system("cls");
cout<<"error , slechte selectie , probeer opnieuw\n";
credits();
}
cin.get();
}```

2. Context would be nice. I happen to know what you're talking about, but others might wonder that you asked a vague question and posted reams of code. Also, have you even tried to use double or float instead of int? Or are you asking us to do it for you?

3. i dont understand anything about float
and no you dont have to do it for me , i cant learn it than , and thats not what i want

4. >i dont understand anything about float
You really don't need to understand. Just replace this:
Code:
```int x;
int y;```
With this:
Code:
```double x;
double y;```
As was already explained to you before you immediately shot back with a request for the exact steps of modifying your code.

5. yeah srry i just cant good english.i give it a try

6. Comparing optellen () and delen() side by side is a revelation.
I suspect the same is true for a few other functions as well.

> cout << "| ____| | ___ | | | | ____| \n";
As a rule, avoid cluttering up the program with trivial presentation code until the substance actually works properly. It's less code to look at, less code for us to wade through when it goes wrong.

> system("cls");
Check the FAQ for better ways of clearing the screen.

> system("cls");
> main();
Calling main() recursively is a no-no.
Use proper loop constructs if you want to repeat stuff.

7. oke it works
big thnx