luc079.c ​
Metadata ​
- Author — Amit Dutta
- Last updated — 08 Feb 2026
- License — MIT License (See the LICENSE file for details)
Problem Statement ​
Problem Statement
Create a structure for bank customers (Acc no, Name, Balance). Write functions to print low balance customers and handle deposits/withdrawals.
Source Code ​
Printing the code
To print this file, open it on GitHub and click Raw before printing, or use the Download Raw button above and print directly from that page.
c
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
struct customer
{
int acc_no;
char name[50];
float balance;
};
void print_low_balance(struct customer *c, int n);
void transaction(struct customer *c, int n, int acc, float amount, int code);
int main()
{
struct customer bank[200] = {
{1001, "Alice", 5000.0},
{1002, "Bob", 500.0},
{1003, "Charlie", 1200.0},
{1004, "David", 800.0},
{1005, "Eve", 2000.0}
};
int n = 5;
int acc, code;
float amt;
// Task 1: Low Balance
printf("--- Customers with Balance < Rs. 1000 ---\n");
print_low_balance(bank, n);
// Task 2: Transaction
printf("\n--- Transaction Menu ---\n");
printf("Enter Account No, Amount, Code (1=Deposit, 0=Withdraw): ");
scanf("%d %f %d", &acc, &amt, &code);
transaction(bank, n, acc, amt, code);
return 0;
}
void print_low_balance(struct customer *c, int n)
{
int i;
for (i = 0; i < n; i++)
{
if (c[i].balance < 1000)
{
printf("Acc: %d, Name: %s, Bal: %.2f\n", c[i].acc_no, c[i].name, c[i].balance);
}
}
}
void transaction(struct customer *c, int n, int acc, float amount, int code)
{
int i, found = 0;
for (i = 0; i < n; i++)
{
if (c[i].acc_no == acc)
{
found = 1;
if (code == 1) // Deposit
{
c[i].balance += amount;
printf("Deposit successful. New Balance: %.2f\n", c[i].balance);
}
else if (code == 0) // Withdraw
{
if (c[i].balance - amount < 1000)
{
printf("The balance is insufficient for the specified withdrawal (Must maintain min 1000).\n");
}
else
{
c[i].balance -= amount;
printf("Withdrawal successful. New Balance: %.2f\n", c[i].balance);
}
}
else
{
printf("Invalid transaction code.\n");
}
break;
}
}
if (!found) printf("Account number not found.\n");
}1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87