Project C
Project C
USING ‘C’
Cource : C Programming and Data Structures Lab
Code : CS152ES
Marks : 10
By
Karthik
23261A04C8
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
return 0;
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
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.
ALGORITHM
Certainly, here's a simplified algorithm for the personal finance tracker program:
Present a menu to the user with options: Add Income, Add Expense, View
Summary, Exit.
- For Add Income and Add Expense, collect user input for amount and
description.
- For Add Income and Add Expense, call the addTransaction function to
add the transaction to the array.
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
struct Transaction
double amount;
char description[MAX_DESCRIPTION_LENGTH];
};
int transactionCount = 0;
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++;
}
else
void displaySummary()
printf("\nTransaction Summary:\n");
printf("-----------------------------------------------\n");
if (transactions[i].type == 'I')
totalIncome += transactions[i].amount;
totalExpense += transactions[i].amount;
printf("-----------------------------------------------\n");
int main() {
int choice;
double amount;
char description[MAX_DESCRIPTION_LENGTH];
do {
printf("4. Exit\n");
scanf("%d", &choice);
switch (choice)
case 1:
scanf("%lf", &amount);
break;
case 2:
scanf("%lf", &amount);
break;
case 3:
displaySummary();
break;
case 4:
break;
default:
return 0;
OUTCOME
*** Personal Finance Tracker ***
1. Add Income
2. Add Expense
3. View Summary
4. Exit
Enter your choice: 1
1. Add Income
2. Add Expense
3. View Summary
4. Exit
1. Add Income
2. Add Expense
3. View Summary
4. Exit
1. Add Income
2. Add Expense
3. View Summary
4. Exit
1. Add Income
2. Add Expense
3. View Summary
4. Exit
Transaction Summary:
-----------------------------------------------
I $75000.00 salary
E $10000.00 shopping
E $5000.00 insurence
-----------------------------------------------
1. Add Income
2. Add Expense
3. View Summary
4. Exit