Any ideas on ways to improve it?
I am new to C++, well programming in general.
Thanks in advance.
BJ
#include <cstdlib>
#include <iostream>
using namespace std;
int c = 0;
char p;
int g =0;
int n = 0;
void D4(int A, int B);
int main()
{
cout<<"Dice emulator writen in C++ by BJ Halterman\n";
while (c!=7)
{
cout<<"\t 1...4 Side\n"; //menu
cout<<"\t 2...6 Side\n";
cout<<"\t 3...8 Side\n";
cout<<"\t 4...10 Side\n";
cout<<"\t 5...20 Side\n";
cout<<"\t 6...100 Side\n";
cout<<"\t 7...Exit\n";
cout<<"Enter your selection please...";
cin>>c;
if(c==1){
cout<<"Enter the number of dice to roll...";
cin>>n;
cout<<"in groups of how many? ";
cin>>g;
D4(n,4);
}
if(c==2){
cout<<"Enter the number of dice to roll...";
cin>>n;
cout<<"in groups of how many? ";
cin>>g;
D4(n,6);
}
if(c==3){
cout<<"Enter the number of dice to roll...";
cin>>n;
cout<<"in groups of how many? ";
cin>>g;
D4(n,8);
}
if(c==4){
cout<<"Enter the number of dice to roll...";
cin>>n;
cout<<"in groups of how many? ";
cin>>g;
D4(n,10);
}
if(c==5){
cout<<"Enter the number of dice to roll...";
cin>>n;
cout<<"in groups of how many? ";
cin>>g;
D4(n,20);
}
if(c==6){
cout<<"Enter the number of dice to roll...";
cin>>n;
cout<<"in groups of how many? ";
cin>>g;
D4(n,100);
}
if (c>7||c<1) {//error
cout<<"That is not a valid selection!\n"<<"\n";
}
}
cout<<"Press any key to exit";
cin.get();
}
void D4(int A,int B)
{
int rn=0;
int T=0;
int t= A/g;
t= A/t;
int gr=t;
int x=0;
while(x<(A/g))
{
rn = ((rand()%(gr*B))+1);
cout<<"\t"<<x+1 <<"...."<<rn<<"\n";
x=x+1;
}
cout<<"\n";
}