# Thread: help with my code easy

1. ## help with my code easy

Sorry about another question. When choose option add interest i press 11 i get the right interest but when i enter number of month 54 i get month 2. Or if i enter any other number i always get 2. why is that. Thank you for your help
Code:
#include<stdio.h>
#include<conio.h>
#include <stdlib.h>

//void saving();
int compound(float a, int b, int c);
int chooseAccountType(void);
//int checkingtotal(int a);
main()
{
char choice;
int interest, month;
int pick,cheq,sav;
int total,total1,value;
int to;
do
{

char a;
printf(" a) Deposit\n");
printf(" b) Withdraw\n");
printf(" d) Account Balance\n");
printf(" e) Exit\n");
printf("Please select one of the choices above (a -> e):");
scanf(" %c",&choice);

if(choice=='a'||choice=='A')
{
pick= chooseAccountType();
printf("the number is %i",pick);
if(pick==1)
{
printf("\nAmmount to be deposit in chequiking=>");
scanf("%i",&cheq);
total=total+cheq;
printf("total %i aa %i",total,cheq);
}
else if(pick==2)
{
printf("\nAmmount to be deposit in saving=>");
scanf(" %i",&sav);
total1=total1+sav;
printf("total1 %i bb %i",total1,sav);
}
}
else if(choice=='b'||choice=='B')
{
pick= chooseAccountType();
printf("the number is %i",pick);
if(pick==1)
{
printf("\nAmmount to be withdraw in chequiking=>");
scanf("%i",&cheq);
total=total-cheq;
printf("total %i aa %i",total,cheq);
}
else if(pick==2)
{
printf("\nAmmount to be deposit in saving=>");
scanf(" %i",&sav);
total1=total1-sav;
printf("total1 %i bb %i",total1,sav);
}
}
else if(choice=='c'||choice=='C')
{

printf("\nWhat is the interest rate to compound annually");
scanf(" %i",&interest);
printf("\ninterest%i",interest);

printf("\nWhat is the number of month");
scanf("% i",&month);                          // When i enter a value i get  an error always get 2
printf("month%i",month);                    // error here

pick= chooseAccountType();
printf("the number is %i",pick);
if(pick==1)
{
printf("heloo");
//value=compound(total,num,it);

}
else if(pick==2)
{
printf("he");
// value=compound(total1,num,it);
}
}
else if(choice=='d'||choice=='D')
{
pick= chooseAccountType();
printf("number two %i", pick);
if(pick==1)
{
printf("Account Balance for chequing=>%i",total);
}
else if(pick==2)
{
printf("Account Balance for saving=>%i",total1);
}
}
else
{
printf("invalid Selection");
}
}
while(choice!='e');

getch();
}

int chooseAccountType(void)
{
int choice;

printf("\n1)Chequing");
printf("\n2)Saving");
printf("\nWhich Account would you like to use=>");
scanf(" %i",&choice);
if(choice==1)
{
return(choice);
}
else if(choice==2)
{
return(choice);
}
}

int compound(float a, int b, int c)
{

};

2. Please do not make a new post everytime you have a different question about the same program with the same code. This question should have been part of this thread you started less than an hour ago.

That being said:
Code:
printf("\nWhat is the number of month");
scanf("% i",&month);
You have a spurious space in your scanf statement. it should be scanf(" %i", &month);

3. Thanks alot