Click here to Skip to main content
15,890,609 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
hahahah i know i always ask. When you click 2nd choice(deposit) instead of showing "enter positive value" it shows "enter negative value"



C++
#include<iostream.h>
#include<stdio.h>
#include<conio.h>
#include<stdlib.h>

void SAVINGS();
int main(){
clrscr();
SAVINGS();
getch();
return 0;
}

void SAVINGS(){
int W,D,B,NB;
char ch;
printf("Enter Account Balance: \t \n");
scanf("%d",&B);
printf("\n\n");
printf("[1] Withdraw    [2] Deposit\t\n");
scanf("%s",ch);

    if (ch=1){
        printf("\n\n");
        printf("Enter a negative value for withdrawal:\t\n");
        scanf("%d",&W);
        NB=B+W;
        printf("\n\n");
        printf("Your new account balance is: %d\t\n",NB);
            if(NB<0){
                printf("Insufficient Fund!\n");
            }
        }

    else if(ch=2){
        printf("\n\n");
        printf("Enter positive value for deposit: \t\n");
        scanf("%d",&D);
        NB=B+D;
        printf("\n\n");
        printf("Your new account balance is: %d\t",NB);
        }
}
Posted
Updated 30-Sep-15 7:53am
v2
Comments
phil.o 30-Sep-15 13:35pm    
I thought comparison operator in C was == instead of =, which is the assignment operator. But I don't know TurboC, OTOH.
CPallini 30-Sep-15 13:56pm    
(virtual) 5.
phil.o 30-Sep-15 13:58pm    
Thanks :)
Patrice T 30-Sep-15 16:48pm    
Hi,
I see that you are asking a lot of questions lately.
This site have an house keeping system, it would be nice to use it.
when you an answer, if the answer is useful, it is nice to accept the answer, it reward the helper.
When the question is solved, you must close the question, it tells the helpers that help is no longer needed here.
By house keepong, you are also rewarded with reputation points.

1 solution

As phil.o already pointed out, the C comparison operator for equality is == (= is the assignment operator). See C Comparison operators/relational operators[^].
 
Share this answer
 
v2

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

  Print Answers RSS


CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900