1. #include<stdio.h>
#include<stdlib.h>
void figureWinnings(int betamount,int option,int number,int
evenodd,int dozenoption);
int
option=0,number=0,evenodd=0,even=0,odd=0,dozenoption=0;
void showInstructions();
int getBetamount();
void makeBet();
figureWinnings(betamount,option,number,evenodd,dozenoption)
;
int main()
{
//Decaring Variable.
int betAmt, winamt;
//This while loop continue to iterate until user stops keeping
bet by pressing 'n' or 'N'.
while(1)
{
char rg;
showInstructions();
int getBetamount();
makeBet();
betAmt = getBetamount();
printf(" Do You want to continue (y/n):");
scanf("%c",&rg);
if(rg=='y'||rg=='Y')
{
continue;
}else
{
break;
}
}
2. return 0;
}
void showInstructions()
{
printf(" ");
printf(" Bet On a Number ,Payout is 36 times the bet
Amount");
printf(" Bet On Even Or odd Number ,Payout is 2 times the
bet Amount");
printf(" Bet On a Dozen,first (1-12),second (13-24),third
(25,36) , Payout is 3 times the bet Amount");
printf(" ");
}
int getBetamount()
{
int betAmt;
printf(" Enter the Bet amount:");
scanf("%d",&betAmt);
return betAmt;
}
void makeBet()
{
printf(" Which type of bet would you like to place?");
printf(" 1.Number");
printf(" 2.Even (or) Odd");
printf(" 3.Dozen ");
scanf("%d",&option);
if(option==1)
{
printf(" Enter the number on which you want to keep bet::");
scanf("%d",&number);
}
else if(option==2)
3. {
printf(" Do you want to bet on even (Or) odd Number ?");
printf(" 4.Even");
printf(" 5.Odd ");
scanf("%d",&evenodd);
}
else if(option==3)
{
printf(" On which dozen you want to bet on ?");
printf(" 6.(1-12)");
printf(" 7.(13-24)");
printf(" 8.(25-36) ");
scanf("%d",&dozenoption);
}
}
int spinWheel()
{
randnum=rand() % 37;
return randnum;
}
void figureWinnings(int betamount,int option,int number,int
evenodd,int dozenoption)
{
if(randnum>=1 && randnum<=36 && randnum==number &&
option>=1 && option<=3)
{
winamt=betamount*36;
printf("The Winamount ::%d",winamt);
}
else if((randnum%2==0 && evenodd==4)|| (randnum%2!=0 &&
evenodd==5) )
{
winamt=betamount*2;
printf("The Winamount ::%d",winamt);
4. }
else if((randnum>=1 && randnum<=12 &&
dozenoption==6)||(randnum>=13 && randnum<=24 &&
dozenoption==7)||(randnum>=25 && randnum<=36 &&
dozenoption==8))
{
winamt=betamount*3;
printf("The Winamount ::%d",winamt);
}
else
{
printf(":: You Lost the bet ::");
}
}
can someone help me whys it saying winamt not declared and
randnum not declared?/
Solution
The winamt and randnum assigend direct to the function calls
which are declared as globally. when the global function starts
it's execution the life span of the variables available through
out the program. But here we declare winamt and randamt with
in the function. Here these two variables available only with in
that block.these two variables doesn't available through out the
program. Hence it shows compilation error these two are not