C Program for ATM Withdrawal with Minimum Balance – Complete Guide for Beginners

अगर आप C program for ATM withdrawal with minimum balance को सीखना चाहते हैं, तो यह blog post आपके लिए ही लिखी गई है। ATM withdrawal system एक classic programming problem है जो beginners को real-world banking logic को code में convert करना सिखाती है। यह problem if-else conditions, comparison operators और basic input/output को एक साथ practice करने का सबसे अच्छा तरीका है।

इस post में हम step-by-step देखेंगे कि C language में ATM withdrawal program कैसे बनाया जाता है जिसमें invalid amount check, insufficient balance check और minimum balance maintenance जैसी conditions शामिल हों। हर concept को simple Hindi में explain किया गया है ताकि कोई भी beginner इसे आसानी से समझ सके।

साथ ही आप यह भी सीखेंगे कि program का code कैसे काम करता है, उसके output cases क्या होते हैं, और किन common mistakes से बचना चाहिए। चाहे आप school project बना रहे हों, college assignment complete कर रहे हों, या simply C programming practice कर रहे हों — यह guide आपके बहुत काम आएगी।

C Program for ATM Withdrawal with Minimum Balance क्या है?

C program for ATM withdrawal with minimum balance एक beginner-level programming problem है जिसमें एक simulated ATM machine का logic C language में implement किया जाता है। इस program में user अपना account balance और withdraw करने की राशि enter करता है, और program automatically decide करता है कि withdrawal possible है या नहीं।

यह problem इसलिए popular है क्योंकि यह एक real-world scenario को represent करती है जिसे हर कोई daily life में experience करता है। जब आप ATM से पैसे निकालते हैं, तो machine automatically कई checks करती है — यही logic हम code में लिखते हैं।

यह Program क्यों सीखना चाहिए?

Conditional Logic की Practice: if-else if-else structure को practically समझने का मौका मिलता है।

  • Real-World Problem Solving: Banking logic को code में convert करना सीखते हैं।
  • Variable Declaration & Arithmetic: float variables और basic calculations का use होता है।
  • Input/Output Handling: scanf और printf functions को confidently use करना आता है।
  • Interview Preparation: यह type के programs C/C++ interviews में अक्सर पूछे जाते हैं।

Program Statement (Problem को समझें)

एक ऐसा C program लिखिए जो user से account balance और withdraw amount input ले और निम्नलिखित conditions के आधार पर output दे:

  1. अगर withdraw amount 0 या उससे कम है → “Invalid withdraw amount” दिखाए।
  2. अगर withdraw amount balance से ज्यादा है → “Insufficient balance” दिखाए।
  3. अगर withdrawal के बाद remaining balance 1000 से कम हो जाए → “Minimum balance of 1000 must be maintained” दिखाए।
  4. अगर ऊपर की कोई condition नहीं लगती → “Take your cash” और remaining balance दिखाए।

यह चारों conditions मिलकर एक complete ATM withdrawal logic बनाती हैं।

Program Code

नीचे दिया गया C program for ATM withdrawal with minimum balance का complete code है:

#include <stdio.h>


int main() {
    float balance, withdraw, remaining;


    printf("Enter Balance: ");
    scanf("%f", &balance);


    printf("Enter Withdraw amount: ");
    scanf("%f", &withdraw);


    // Check whether the withdrawal amount is valid
    if (withdraw <= 0) {
        printf("Invalid withdrawal amount.\n");
    }
    // Check whether sufficient balance is available
    else if (withdraw > balance) {
        printf("Insufficient balance.\n");
    }
    else {
        // Calculate the remaining balance
        remaining = balance - withdraw;


        // Check whether minimum balance can be maintained
        if (remaining < 1000) {
            printf("Minimum balance of 1000 must be maintained.\n");
        }
        else {
            printf("Take your cash.\n");
            printf("Remaining balance: %.2f\n", remaining);
        }
    }


    return 0;
}

Program Output – सभी Cases

इस program को अलग-अलग inputs के साथ run करने पर निम्नलिखित outputs मिलते हैं:

Case 1 – Successful Withdrawal

▶️ Output Result
Enter Balance: 5000 Enter Withdraw amount: 2000 Take your cash Remaining balance: 3000.00

यहाँ 5000 – 2000 = 3000 है जो 1000 से ज्यादा है, इसलिए withdrawal successful रही।

Case 2 – Minimum Balance Violation

▶️ Output Result
Enter Balance: 5000 Enter Withdraw amount: 4500 Minimum balance of 1000 must be maintained

यहाँ 5000 – 4500 = 500 है जो 1000 से कम है, इसलिए withdrawal रोकी गई।

Case 3 – Insufficient Balance

▶️ Output Result
Enter Balance: 5000 Enter Withdraw amount: 6000 Insufficient balance

यहाँ withdraw amount (6000) balance (5000) से ज्यादा है।

Case 4 – Invalid Amount

▶️ Output Result
Enter Balance: 5000 Enter Withdraw amount: -200 Invalid withdraw amount

Negative amount enter करने पर invalid message आता है।

Code Explanation – Line by Line समझें

1. Header File Include करना

#include <stdio.h>

stdio.h header file include की जाती है जिससे printf (output display करना) और scanf (input लेना) functions का use किया जा सके। यह C programming का सबसे basic और जरूरी step है।

2. Variables Declare करना

float balance, withdraw, remaining;

तीन float type variables declare किए गए हैं:

  • balance — user का current account balance store करता है।
  • withdraw — user जितना पैसा निकालना चाहता है वो store करता है।
  • remaining — withdrawal के बाद बची हुई राशि store करता है।

float type इसलिए use किया गया है क्योंकि balance में decimal values (जैसे 1500.50) भी हो सकती हैं।

3. Remaining Balance Calculate करना

remaining = balance – withdraw;

यह statement withdrawal से पहले calculate किया जाता है ताकि बाद की conditions में remaining variable ready हो। यह एक simple arithmetic operation है।

4. Conditions Check करना (if-else if ladder)

यह program का सबसे important हिस्सा है। चारों conditions एक specific order में check होती हैं:

पहली condition:

if (withdraw <= 0)

अगर user ने 0 या negative amount enter किया तो invalid message show होगा। यह condition सबसे पहले check होती है।

दूसरी condition:

else if (withdraw > balance)

अगर withdraw amount, available balance से ज्यादा है तो insufficient balance का message show होगा।

तीसरी condition:

else if (remaining < 1000)

यह minimum balance condition है। अगर withdrawal के बाद 1000 रुपये से कम बचते हों तो transaction रोक दी जाती है।

else block (Successful Case):

else
{
	printf("Take your cash\n");
	printf("Remaining balance: %.2f\n", remaining);
}

जब कोई भी condition fail नहीं होती तो user को cash मिलती है और updated balance display होता है।

5. Format Specifier %.2f का महत्व

%.2f format specifier float value को दो decimal places तक display करता है। इससे output professional और readable लगता है — जैसे 3000.00 या 1500.75

Conditions का Order क्यों Important है?

C program for ATM withdrawal with minimum balance में conditions का order बहुत मायने रखता है। अगर withdraw > balance को remaining < 1000 से पहले check न किया जाए, तो जब balance 500 हो और user 600 निकालना चाहे तो remaining negative हो जाएगी जो गलत output देगी।

सही order हमेशा यही होना चाहिए:

  1. Invalid amount check
  2. Insufficient balance check
  3. Minimum balance check
  4. Successful withdrawal

Common Mistakes जो Beginners करते हैं

  • int की जगह float use न करना: Balance में decimal हो सकते हैं, इसलिए float जरूरी है।
  • Conditions का गलत order: पहले invalid check, फिर insufficient check करना जरूरी है।
  • remaining की गलत calculation: Conditions से पहले remaining calculate करना न भूलें।
  • scanf में & operator miss करना: scanf(“%f”, &balance) में & जरूरी है।
  • %.2f की जगह %f use करना: Output formatting के लिए %.2f ज्यादा professional है।

Program को और बेहतर कैसे बनाएं?

यह basic program और भी advanced बनाया जा सकता है:

  • Loop add करें: User को multiple transactions करने दें जब तक वो exit न चाहे।
  • PIN verification जोड़ें: User से 4-digit PIN enter करवाएं और validate करें।
  • Multiple accounts: Array of structures use करके multiple user accounts handle करें।
  • Transaction history: हर withdrawal को एक list में store करें।
  • Daily limit: एक दिन में maximum withdrawal limit implement करें।

Conclusion (निष्कर्ष )

C program for ATM withdrawal with minimum balance एक ऐसा beginner-friendly project है जो C programming के fundamentals — variables, arithmetic operators, if-else conditions और formatted output — को एक साथ practice करने का मौका देता है। इस program को समझने के बाद आप real-world problems को logical conditions में convert करने की skill develop कर लेते हैं जो आगे जाकर complex programming projects में बहुत काम आती है। Code को carefully पढ़ें, हर line को समझें, और खुद type करके run करें — यही सबसे तेज़ सीखने का तरीका है।

अब आपकी बारी है! इस program को अपने compiler में run करें, अलग-अलग values try करें, और फिर इसे upgrade करें — जैसे PIN add करना, loop implement करना, या daily limit लगाना। अगर आपको कोई error आए या कोई concept समझ न आए तो नीचे comment करें। ऐसे ही और C programming programs और tutorials के लिए इस blog को bookmark करें और अपने दोस्तों के साथ share करें जो C language सीख रहे हैं।

Frequently Asked Questions

Q 1: इस program में float variables क्यों use किए गए हैं, int क्यों नहीं?
Ans: float इसलिए use किया गया है क्योंकि real banking में balance और withdrawal amounts में decimal values हो सकती हैं जैसे ₹1500.50 या ₹2750.75। अगर int use करें तो decimal part automatically drop हो जाएगा और output inaccurate होगा।
Q 2: remaining को conditions से पहले क्यों calculate किया गया है?
Ans: remaining = balance – withdraw को conditions से पहले इसलिए रखा गया है ताकि तीसरी condition (remaining < 1000) में इस value को directly use किया जा सके। अगर इसे बाद में calculate करते तो code redundant और complex हो जाता।
Q 3: क्या यह program negative balance पर काम करेगा?
Ans: नहीं, पहली condition withdraw <= 0 invalid withdrawals को रोकती है, और दूसरी condition withdraw > balance यह ensure करती है कि balance कभी negative नहीं होगा। यह program properly validated है।
Q 4: Minimum balance limit को 1000 से बदलकर कुछ और कैसे करें?
Ans: Code में remaining < 1000 की जगह remaining < 500 या कोई भी desired value लिखें। और भी flexible बनाने के लिए एक separate variable int minBalance = 1000; declare करें और condition में remaining < minBalance लिखें।
Q 5: क्या यह program एक real ATM system की तरह काम करता है?
Ans: यह program real ATM system का simplified educational version है। Real ATM में network connectivity, encrypted PIN, card validation, database integration और बहुत सारी security features होती हैं। लेकिन core withdrawal logic — invalid check, balance check, minimum balance — इस program में accurately implement है।

Leave a Comment

Your email address will not be published. Required fields are marked *

Scroll to Top