0% found this document useful (0 votes)
350 views

Project C

The document describes a C program for a personal financial tracker. It includes sections on motivation, objectives, introduction to C, key features used, the algorithm, and source code. The program allows users to add income and expense transactions, view a summary of all transactions including totals, and exit. It demonstrates the use of C programming concepts like functions, arrays, structures, loops, and input/output functions.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
350 views

Project C

The document describes a C program for a personal financial tracker. It includes sections on motivation, objectives, introduction to C, key features used, the algorithm, and source code. The program allows users to add income and expense transactions, view a summary of all transactions including totals, and exit. It demonstrates the use of C programming concepts like functions, arrays, structures, loops, and input/output functions.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 13

REPORT ON PERSONAL FINANCIAL TRACKER

USING ‘C’
Cource : C Programming and Data Structures Lab
Code : CS152ES
Marks : 10

By
Karthik
23261A04C8

DEPARTMENT OF ELECTRONICS AND COMMUNICATION


ENGINEERING

MAHATMA GANDHI INSTITUTE OF TECHNOLOGY (A)


MOTIVATION
The inspiration for the personal finance tracker project stemmed from the desire
to empower individuals with a tool for financial awareness, budgeting, and
improved financial habits.
The program aims to enhance users awareness of their financial activities by
providing a structured platform to record and categorize income and expances.

OBJECTIVES
The project addresses the common challenge of financial management by offering
a tool that enhances awareness , improved financial habits, motivation and
accountability, decision making and facilitates effective budgeting for individuals'
improved financial well-being.

INTRODUCTION TO 'C'
C is a general-purpose programming language created by Dennis Ritchie at the
Bell Laboratories in 1972.
It is a very popular language, despite being old. The main reason for its popularity
is because it is a fundamental language in the field of computer science.

There are 6 basic sections responsible for the proper execution of a program.
Sections are mentioned below:

Documentation

Preprocessor Section

Definition

Global Declaration

Main() Function

Sub Programs
STRUCTURE
// Description , Name of the program , Programmer name ,etc.......

#include<stdio.h> // preprocessor

#include<math.h> // preprocessor

#define BORN 2005 // Defination

int age (int current) // Global declaration

int main (void) // main( ) function

int current = 2021;

printf("Age: %d", age(current));

return 0;

int age(int current) //Subprograms

return current - BORN;

The steps of execution of c program are C code then Processing then Compiler
then Assembler then Linker then Loader.
Key features of ‘C’ programming used in the project
The C program for the personal finance tracker employs several fundamental
concepts, functions, and structures:

1. Functions:
Basic building blocks of a c program

addTransaction: This function adds a new transaction to the array of


transactions. It takes parameters such as transaction type ('I' or 'E'), amount, and
description. It encapsulates the logic for adding transactions, promoting
modularity.
displaySummary: Responsible for calculating and displaying a summary of
transactions, including total income, total expense, and net balance. Enhances
readability and simplifies code organization.
'main': The main function orchestrates the program's execution, presenting a
menu for user interaction, processing user choices, and invoking relevant
functions accordingly.

2. Arrays:
Collection of similar data types.

The transactions array stores transaction data efficiently. It holds structures with
information about the type of transaction ('I' or 'E'), the transaction amount, and
a description.

3. Structures:
A way to group several related variables into one place. It can contain many
different data types.
The struct Transaction structure encapsulates the data related to each
transaction, promoting a clean and organized representation of transaction
details.
4. Loops and Conditional Statements:
A do-while loop allows the user to repeatedly interact with the program until
choosing to exit. This loop ensures a continuous and user-friendly experience.

switch statements inside the loop direct the program's flow based on the user's
menu choice. This employs conditional statements for decision-making.

5. Input/Output Functions:
The printf function is used for displaying messages and the menu to the user.
The scanf function collects user input, allowing for dynamic interaction and input
validation.

6. User-Defined Functions:
The addTransaction' and 'displaySummary functions encapsulate specific
functionalities, promoting code modularity and readability.

These C language features collectively contribute to the development of a clear,


concise, and functional personal finance tracker, showcasing the language's
simplicity, control, and efficiency in addressing real-world problems.

ALGORITHM
Certainly, here's a simplified algorithm for the personal finance tracker program:

STEP 1. Initialize Variables:

Initialize necessary variables, including arrays and counters.

STEP 2. Display Main Menu:

Present a menu to the user with options: Add Income, Add Expense, View
Summary, Exit.

STEP 3. User Interaction Loop:


• Use a do-while loop to repeat the following steps until the user chooses to exit.
3.1. User Chooses an Option:

-Display the menu and prompt the user to choose an option.

3.2. Perform Operation based on User's Choice:

- Use a switch statement to execute the appropriate functionality based


on the user's choice.

3.3. User Inputs Transaction Data:

- For Add Income and Add Expense, collect user input for amount and
description.

3.4. Perform Transaction Operation:

- For Add Income and Add Expense, call the addTransaction function to
add the transaction to the array.

3.5. Display Appropriate Messages or Summary:

- For View Summary, call the displaySummary function to show a


summary of transactions.

STEP 4. Display Exit Message:

• Display a closing message when the user decides to exit.

STEP 5. End the Program:

Terminate the program.

This algorithm outlines the main steps of the personal finance tracker,
emphasizing user interaction, transaction handling, and summary display. The
actual C code provides the implementation details for each step.
SOURCE CODE
#include <stdio.h>

#include <stdlib.h>

#include <string.h>

#define MAX_TRANSACTIONS 50

#define MAX_DESCRIPTION_LENGTH 100

struct Transaction

char type; // 'I' for income, 'E' for expense

double amount;

char description[MAX_DESCRIPTION_LENGTH];

};

struct Transaction transactions[MAX_TRANSACTIONS];

int transactionCount = 0;

void addTransaction(char type, double amount, const char *description)

if (transactionCount < MAX_TRANSACTIONS)

transactions[transactionCount].type = type;

transactions[transactionCount].amount = amount;

strncpy(transactions[transactionCount].description,description,MAX_DESCRIPTION_LENGTH - 1);

transactions[transactionCount].description[MAX_DESCRIPTION_LENGTH - 1] = '\0';

transactionCount++;

printf("Transaction added successfully.\n");

}
else

printf("Transaction limit reached. Cannot add more transactions.\n");

void displaySummary()

double totalIncome = 0, totalExpense = 0;

printf("\nTransaction Summary:\n");

printf("%-10s %-15s %-30s\n", "Type", "Amount", "Description");

printf("-----------------------------------------------\n");

for (int i = 0; i < transactionCount; i++)

printf("%-10c $%-14.2lf %-30s\n", transactions[i].type, transactions[i].amount,


transactions[i].description);

if (transactions[i].type == 'I')

totalIncome += transactions[i].amount;

else if (transactions[i].type == 'E')

totalExpense += transactions[i].amount;

printf("-----------------------------------------------\n");

printf("Total Income: $%.2lf\n", totalIncome);


printf("Total Expense: $%.2lf\n", totalExpense);

printf("Net Balance: $%.2lf\n", totalIncome - totalExpense);

int main() {

int choice;

double amount;

char description[MAX_DESCRIPTION_LENGTH];

do {

printf("\n*** Personal Finance Tracker ***\n");

printf("1. Add Income\n");

printf("2. Add Expense\n");

printf("3. View Summary\n");

printf("4. Exit\n");

printf("Enter your choice: ");

scanf("%d", &choice);

switch (choice)

case 1:

printf("Enter income amount: $");

scanf("%lf", &amount);

printf("Enter description: ");

scanf(" %[^\n]s", description);

addTransaction('I', amount, description);

break;
case 2:

printf("Enter expense amount: $");

scanf("%lf", &amount);

printf("Enter description: ");

scanf(" %[^\n]s", description);

addTransaction('E', amount, description);

break;

case 3:

displaySummary();

break;

case 4:

printf("Exiting the program. Goodbye!\n");

break;

default:

printf("Invalid choice. Please try again.\n");

} while (choice != 4);

return 0;

OUTCOME
*** Personal Finance Tracker ***

1. Add Income

2. Add Expense

3. View Summary

4. Exit
Enter your choice: 1

Enter income amount: $75000

Enter description: salary

Transaction added successfully.

*** Personal Finance Tracker ***

1. Add Income

2. Add Expense

3. View Summary

4. Exit

Enter your choice: 2

Enter expense amount: $10000

Enter description: shopping

Transaction added successfully.

*** Personal Finance Tracker ***

1. Add Income

2. Add Expense

3. View Summary

4. Exit

Enter your choice: 2

Enter expense amount: $5000

Enter description: insurence

Transaction added successfully.

*** Personal Finance Tracker ***

1. Add Income

2. Add Expense
3. View Summary

4. Exit

*** Personal Finance Tracker ***

1. Add Income

2. Add Expense

3. View Summary

4. Exit

Enter your choice: 3

Transaction Summary:

Type Amount Description

-----------------------------------------------

I $75000.00 salary

E $10000.00 shopping

E $5000.00 insurence

-----------------------------------------------

Total Income: $75000.00

Total Expense: $15000.00

Net Balance: $60000.00

*** Personal Finance Tracker ***

1. Add Income

2. Add Expense

3. View Summary

4. Exit

Enter your choice: 4

Exiting the program. Goodbye!


LEARNING OUTCOMES AND CONCLUSION
The personal finance tracker project delivers a practical tool for managing
income, expenses, and budgeting. Future extensions may include a user-friendly
graphical interface, persistent data storage, advanced budgeting features,
security enhancements, data analysis tools, mobile application development, and
support for multiple currencies, offering a comprehensive financial management
solution.

You might also like