Tally
Tally
is reading accounting software for accounting society which performs a facility
to store the implementation of ledger inventory etc.
Tally
4.5, Tally 5.4, Tally 6.3, Tally 7.2, Tally 8.0. Tally 9.0, Tally 9.2
Tally
4.5 – It is a dos base tally programme
Tally
5.4 - It is a window base tally programme
Tally
6.3 – It is also windows base programme
Tally
7.2 and Tally 8.0 – These two version are support or contains all the
facilities of tally 6.3 and also support a additional facilities of vat (value
added Tax)
WHAT IS ACCOUNTING:
Accounting is the art of recording, classifying and Summarizing in a significant manner and in term of money, transaction and events which are in part and least of a financial char and integration result there off.
BRANCHES OF ACCOUNTINGS:
Accountings are three branches:
1. Financial Accounting
2. Cost Accounting
3. Management Accounting.
1. Financial Accounting: This accounting deals with the profit or loss mode during a project.
2. Cost Accounting: This accounting deal with the cash includes for caring out the various activities to enable management exercise cost control.
3. Management Accounting: Management Accounting deals with the management significant and necessaries conformation for decision making control etc.
TYPES OF ACCOUNTS:
Personal Account:
The personal accounts are these accounts which deal with an individual corporate body or institution for example: accounts related to customers, creditor’s debtors, owners, bank, firms. Capitals are Personal accounts.
Impersonal Account:
Impersonal account are those account which is not personal account.
Tangible Account:
These accounts are used to keep records of physical things. It can be fixed or current in nature like property, cash, furniture etc.
Intangible Account:
The intangible accounts are used to keep records of volatile things which can’t be seen or touched but they can be measured in terms of money. For example: brand name, god will, patent etc.
Real Account
It related to any asset of business form. There are two types of assets
(a) Fixed asset
(b) Current asset
(a) Fixed asset: Any asset which is existing a business from more than one year. Ex: furniture accounts etc.
(b) Current asset: Any asset to exists in a business from more than one year. Ex-Bank account, cash account, prepaid account etc.
Nominal Account:
This account deals with expenses, losses, income and profit. Ex the rent of building, staff salary, conveyance transportation charges and so on.
Debit and credit:
Debit and credit are two important terms used in accountancy.
1. Personal account:
a. Debit the receiver
b. Credit the Giver
2. Real account:
a. Debit the receiver
b. Credit the Giver
3. Nominal Account:
a. Debit the receiver
b. Credit the Giver
Rules of Debit and Credit in Account:
1. Personal Account
a. Credit is the giver
b. Debit is the receiver
2. Real account
a. Credit what goes out
b. Debit what comes in
3. Nominal account
a. Credit all income and gains and
b. Debit all expenses and losses
1.
Start-
Programme Tally 7.2
2.
Click
on tally executable icon on windows desktop.
1.
Name
– To enter the company name
2.
Mailing
name – To enter the company corresponding name.
3.
Address
– To enter the corresponding company address name.
4.
State
– To enter the state of company.
5.
Pin
code – To enter the postal index no. of company.
6.
E-mail
address – To enter the electronic mail address of company.
7.
Use
Indian vat – To Inter No/Yes
8.
Local
sale tax No- To enter the sale tax no. of company which is provide through
state Govt. department of sale tax.
9.
Inter
state sale tax no – To Inter the no which is provides through sale tax
department central Govt. PAN (Permanent account no).
10. Currency Symbol
– To enter the currency symbol of India.
11. Maintain – It
contains two categories
a.
Accounts
only
b.
Accounts
which inventory
a.
Accounts
only- It manage only accounts
b.
Accounts
with inventory – It manage account and stock item details.
12. Financial year
from
13. Book beginning
from{ These two data format are equal 12 &13}
14. Tally vault password
15. Use security
control {The two option are use for the protect the another user.-14,15}
16. Base currency
information – It is use for display all the currency information about active
company.
(Tips)
1.
Press
“Y” for the accept company and “N: for cancel.
2.
After
complete above procedure the define company will be display on screen.
1.
Tally
information bar
2.
Button
bar
3.
Date
and time tab
4.
Advance
calculator
5.
Tally
license bar
6.
Gate
way of tally
7.
Company
information bar.
There are divided into three parts
a.
Master
b.
Transaction
vouchers
c.
Reports.
Master
–
It give a facility to add account master and inventory master in active
company.
Transaction
vouchers
– All the implementation of accounting manage through the group of information.
Report
–
It give a facility to display the statements about current transaction.
It
contains three categories
1.
Account
information
2.
Inventory
information
3. Import masters.
Account
information –
It contains three categories
1.
Create
– To create a new ledger
2.
Display
– To display on existing ledger
3. Alter – To edit or modify existing ledger.
Inventory information – It is used for to insert or to add item is current company.
Account information – It news collect to all the primary information about active party.
In account information are base on
account groups. And In tally 28th of accounts groups are available.
1.
Bank
account – All the bank ledger are manage through bank account information.
2.
Bank
OD account – It means bank over draft account.
3.
Capital
account – Implementation of first amount or investment.
4.
Cash
in hand – Hard cash.
5.
Current
assets – All the physical stock sundry debtors account etc.
6.
Current
liabilities – Amount
7.
Direct
expenses- - When the money will outward mode through direct method. Ex- wages
account, Carriage account.
8.
Indirect
expenses – When the money will inward mode without any investment.
9.
Direct
income- When the money will inward mode without any investment.
10. Duties and taxes
– Govt. tax.
11. Indirect income
– When the money will inward mode through indirect method (commission).
12. Investment –
First implementation of the money
13. Lone liabilities
– Bank lone.
14. Purchase account
– The method of inward item
15. Sales account-
The method of outward item.
16. Stock in hand –
Physical stock.
17. Sundry creditor
– Sealer
18. Sundry debtor –
Buyer
19. Suspense account – When an account create mistry then suspense account will be managed
Ledger:
It
is used for to managed for all the primary inform above the party.
Ledger
creation:
1.
Click
on account information
2.
Click
on ledger
3. Click on create from single ledger creation
Structure
for Ledger creation:
Name- To enter the
party name.
Under- To enter the of
party
Opening balance- To enter the
opening amount of ledger.
Mailing and related details – To enter the corresponding details of active ledger.
(Tips) Press
“Y” for accepts the ledger and “N” for cancel.
Sundry creditor (X) Staff
payment
Sundry debtor (Y) Petrol
expense
Purchase account Mobile
Voucher
Sales account Electric
Bill
House rent Telephone
Bill
Office expense
Tran pointing
It
is most essential part for inventory i.e. without units of measure inventories
are not managed with an account.
Procedure
for units of measure:
1.
Click
on inventory information
2.
Click
on units of measure
3.
Click
on create.
Structure
of Units of measure:
1.
Type
simple – It is the default setting.
2.
Symbol
– To enter the units symbol.
3.
Formal
name – To enter the full name of symbol.
4.
No
of decimal places – To enter “0”.
(Tips) Press “Y” accepts the units of measure and “N” for cancel.
Inventory
creation:
It
is used for towards item in active company.
Procedure:
1.
Click
on inventory information.
2.
Click
on stock item.
3.
Click
on create from single stock item.
(Tips) After complete all above procedure the item creation window will be on screen.
Name – To enter the name of Item.
Allias – To enter the full name of item.
Under – To enter the primary by default.
Units – To enter the units of measure.
Rate of duty – To enter the 4.
Opening balance – To enter opening item,
quantities and rate per individual.
Value – The value will be calculated automatic.
(Tips) Press “Y” accepts inventory and “N” for cancel.
2. Transaction voucher :
Voucher
types.
Shortcut
key Purchase
F9 Purchase
voucher
F8 Sales
voucher
F7 Journal
voucher
F6 Receipt
voucher
F5 Payment
voucher
F4 Contra voucher
Purchase
voucher:
Purchase
voucher managed by the button key F9 It is categories two types.
a.
Credit
purchase.
b.
Cash
purchase.
Structure
for credit purchase:
1.
Click
on account voucher.
2.
Click
on F9.
3.
Party
account Name – To enter the party name (Sundry creditor)
4.
Current
balance – To display of current balance of active party.
5.
Purchase
ledger – To enter the purchase account.
6.
Name
of item – To enter the item name quintiles and rate per individual.
7.
Amount
– The amount will be calculated automatic.
8.
Narration
– To enter remarks for the active voucher.
(Tips) Press “Y” for accepts the voucher and “N” for cancel
Structure
for cash purchase:
1.
Click
on accounting voucher.
2.
Click
on F9
3.
Party
account name – To enter Cash.
4.
Current
balance – To display the current balance of active party.
5.
Purchase
ledger – To enter purchase account.
6.
Name
of Item- To enter the item name.
7.
Quantity-
To enter the item quantity and rate per individual.
8.
Amount
– The amount will be calculated automatic .
9.
Narration-
To enter remarks for the item voucher for the active voucher.
(Tips) Press “Y” for accepts the voucher and “N” for the cancel.
Sales
Voucher:
When
the items are outward mode then sales voucher will be managed by button key F8
Sales voucher divided two types (a) cash sale (b) credit sale.
a.
Cash sale.
1.
Click
on account voucher
2.
Click
on F8
3.
Party
account Name – To enter the cash
4.
Sale
ledger – To enter the sales account
5.
Name
of item – To enter the item name, quantity, rate per individual.
6.
Amount
– The amount will be calculated automatic
7.
Narration
– Enter remarks for the active voucher.
(Tips) Press “Y” accepts for the voucher
and “N” for cancel.
b.
Credit sale.
1.
Click
on account vouchers
2.
Click
on F8
3.
Party
account Name – To enter the sundry debtor
4.
Sales
ledgers name- To enter the sales account
(Tips) Other entries are same as cash sale.
Journal
Voucher(F7)
It is use for to adjust the a/c
Particulars
By- To enter the expenses account name
Debit- To enter the debit amount
To- To enter the adjust amount party
name.
Credit- To enter the adjustment amount
Type of reference- To enter on account
(tips)-Press “Y” accept the voucher and
“N” for cancel
Dr & Cr
Dr used for to “BY”
Cr used for to “To”
When
the money will be in worm mode through cash or check them the receipt voucher will
be managed by the button key F6. It’s two types (a) Cash (b) Check.
1.
Click
on accounting voucher
2.
Click
on F6
3.
Account
– To enter the cash
4.
Particulars
– To enter party name (sundry debtor)
5.
Amount-
To enter the receipt amount
6.
Narration
– To enter remarks for the active voucher
(Tips) Press “Y” accepts the voucher and
“N” for cancel
1.
Click
on accounting voucher.
2.
Click
on F6
3.
Accounts-
To enter the bank name.
4.
Particulars
– To enter party name (Sundry debtor).
5.
Amount
– To enter the receipt check amount.
6.
Narration-
To enter the check (Number for remarks)
(Tips) Press “Y” for accepts the voucher
and “N” for cancel.
When
the money will be out word mode then the payment voucher will be managed by the
button key F5 payment voucher divided into two types one is payment through
cash and other is payment through bank.
1.
Click
on accounting voucher
2.
Click
on F5
3.
Account
– To enter the cash.
4.
Particulars
– To enter the paid party name (Sundry debtor).
5.
Amount-
To enter the paid amount.
6.
Narration-
To enter remarks active voucher.
(Tips) Press “Y” account for voucher and
“N” for cancel.
1.
Click
on accounting voucher.
2.
Click
on F5
3.
Accounts-
To enter the bank name.
4.
Particulars
– To enter the party name (Sunday debtor)
5.
Amount
– To enter the paid amount.
6.
Narration-
To enter remarks for active voucher.
(Tips) Press “Y” for the accepts the
voucher and “N” for the cancel.
All
the bank transactions are managed through contra voucher then contra voucher
will be managed by button key F4. Contra voucher is divided into two types (a) Cash deposit (b) Cash with drawl.
1.
Click
on accounting voucher
2.
Click
on F4
3.
Account
– To enter the bank name.
4.
Particular
– To enter the cash.
5.
Amount
– To enter the deposit the amount.
6.
Narration
– To enter remarks for active voucher.
(Tips)
1.
Press
“Y” for the accepts the voucher and “N” for the cancel.
2.
After
the complete the above procedure the cash will be auto subtract from cahs in
hand and add with bank account.
1.
Click
on accounting voucher.
2.
Click
on F4
3.
Account
– To enter the cash.
4.
Particulars
– To enter the bank name.
5.
Amount
– To enter the withdrawal amount.
6.
Narration-
To enter remarks for active voucher
(Tips) Press “Y: accepts the voucher and
“N” for cancel.
It
is managed through inventory voucher in the propose of stock journal is collect
all the items individual from go down. At sail into a header item. It is also
called as inventory voucher.
1.
Create
a header item through inventory information.
2.
Click
on inventory voucher.
3.
Structure
of inventory voucher divided into two types (a) sources of consumption (b)
Destination production.
a.
Sources
of consumption: To collect the all item individual from go down
b.
Destination
production: To enter a header item name after complete all above procedure the
source items are subtract from go sown at sale into a header item.
Procedure: At first item purchase then
click stock journal.
Name
of item-To enter the item name
Qty.-
To enter the item qty.
Rate-
To enter item rate.
Amount
– amount will calculated automatic.
Destination production.
Qty- To enter Item Qty. (1)
Rate – To enter the production rate.
(Tips) After complete all above
procedure the stock journal item are subtracts from go down and grouped in a
header Item.
Round
up is purchase voucher and sales voucher round up categories into types.
a.
Increase
round up.
b.
Decrease
round up.
Increase round up – It is used for after
50
Decrease round up- It is used for below
50
1.
Increase
round up in the group of direct incomes.
2.
Decrease
round up in the group of direct expenses
1.
Click
on accounting voucher.
2.
Click
on F9.
3.
Party
account name – To enter the party name.
4.
Purchase
ledger – To enter purchase account.
5.
Name
of Item – To enter the Item name qty. and rate per individual.
Tips- Amount will be calculated
automatic.
Increased Roundup – To enter the round
up amount including “+” for ex (+.20)
Tips- Same entry is increase round up
only one change will be maintain (-) Symbol except (+).
It contains all the internal setting for
active company.
Separated discount column on invoice
(Yes)
1.
Click
on account voucher.
2.
Click
on F8
3.
Party
account name – To enter the party name.
4.
Current
balance – To display the current balance of active party.
5.
Sales
ledger – To enter the sale ledger.
6.
Name
of Item – To enter the item name.
7.
Quantity
– To enter the item quantity.
8.
Rate
– To enter the rate per individual.
9.
Discount
– To enter the discount the percentage.
10. Amount – The
amount will be auto subtract through discount.
(Tips) Press “Y: accepts the voucher and
“N” for cancel.
It
is used for to enter discount at the time of purchase.
1.
Create
a ledger purchase discount.
2.
Under
– Direct income.
Tips – Press “Y” accepts the ledger and
“N” for cancel.
1.
Click
on account voucher
2.
Click
on F9
3.
Party
account name – To enter the party name
4.
Current
balance – To display the current balance of active party.
5.
Purchase
ledger – To enter the purchase ledger.
6.
Name
of item – To enter the item name, qty and rate per individual.
7.
Purchase
discount – To enter purchase discount in percentage with subtract symbol.
(Tips)- The amount will be auto adjust
from the grand Total amount.
Use
invoice Mode for credit notes (yes)
Use
invoice mode for debit notes (yes)
When
the purchase items returns the Sunday creditor or the root company. Then debit note will be managed by the button
key (ctrl + f9)
1.
Click
on accounting voucher
2.
Click
on ctrl+f9
3.
Party
account name – To enter the party name creditor
4.
Current
balance – To display the current balance of active party.
5.
Purchase
ledger – To enter the purchase account.
6.
Name
of item- To enter the return item name qty. rate per individual.
Tips
1.
Press
“Y” accepts for the voucher and “N” for cancel
2.
The
return item amount will be auto adjust through creditor.
Credit
Note:
When
the sale items are return through the sundry creditor from sundry debtor then
the credit note managed will be by the button key (ctrl+f8)
1.
Click
on account voucher
2.
Click
on Ctrl+F8
3.
Party
account name – To enter the party name (sundry debtor)
4.
Current
balance – To display the current balance of active party.
5.
Sales
ledger – To enter sales account.
6.
Name
of item – To enter item name, qty, rate per individual.
Tips-
1.
Press
“Y” for accept the voucher and “N” for cancel
2.
The
amount will be auto adjust through the debtor account.
1.
Click
an accounting features
2.
Click
on F11
(3) Use different actual and billed
quantity (yes)
(This option is used for the active free
item entry in purchase and sale)
Structure
for free item entry in purchase:
1.
Click
on accounting voucher.
2.
Click
on F9
3.
Party
accounting name – To enter the party name
4.
Purchase
ledger – To enter the purchase ledger.
5.
Name
of item – To enter the item name
6.
Actual
– To enter the receive item quantity
7.
Billed
– To enter the billing item quantity.
8.
Rate
– To enter the rate per individual.
9.
Amount-
The amount will be calculated automatic with billing item quantity.
10. Narration – To
enter remarks for the active voucher
(Tips)
1.
Press
“Y” for accepts the voucher and “N” for cancel.
2.
Same
procedure used for free item entry in sale voucher.
(4)
Maintain Batch wise details (Yes)
Set expiry dates for batches (Yes)
These two options are used for to enter
batch no manufacture date and expiry date in item.
Press “Y” for accepts the configuration
and “N” for cancel.
1.
Click
on inventory information.
2.
Click
on stock item.
3.
Click
on create.
4.
Name-
To enter the item name
5.
Units-
To enter the units of measure.
Maintain in batches (Yes)
Track date of manufacture (Yes)
Press
“Y” accepts the item and “N” for cancel.
Structure for purchase ledger:
1.
Click
on accounting voucher
2.
Click
on F9
3.
Party
account name- To enter the party name.
4.
Purchase
ledger- To enter the purchase account.
5.
Name
of item- To enter the name of item.
6.
Manufacture
date – To enter the manufacture date of item.
7.
Expiry
date- To enter the expiry date of item.
8.
Batch
no – To enter Identify for item.
9.
Quantity-
To enter the item quantity and rate per individual.
10. Amount- The
amount will be calculated automatic.
(Tips)
The
important feature of manufacture dates and expiry dates expiry item can’t be
sales towards other i.e all the item of batch no sale in between the date of
manufacture and expiry.
Activate interest calculation (Yes)
Use advanced parameter (Yes)
The
default credit period is must essential for interest calculation.
Sundry creditor (Ledger):
Default
credit period- To enter the default credit limit of the sundry creditor
Interest parameter
Calculation
interest transantion by transanion (yes)
Over write parameters for each
transantion (No).
Rate – To enter the Interest rate in
percentage.
Per- To enter the 30 day month.
On- To enter credit balance only.
Applicabitite- To enter always.
Calulate from- To enter the effective
day of transion
Rounding- To enter the normal rounding
Limit- To enter one
Default credit period- To enter the
credit limit of sundry debtor.
Activate interest calculation (Yes).
Rate – To enter the Interest rate in percentage
Per- To enter the 30 day of month
On- To enter the debit balance only
Applicabilite- To enter always.
Calculate from – To enter the effective
date of transaction.
Rounding – To enter the normal rounding.
Limit – To enter one.
Sales Account: Same configuration as
Sunday debtor.
Display the interest statement :
1.
Click
on display
2.
Click
on statement of accounts
3.
Click
on interest calculation
4.
Click
on interest reliable or interest payable.
This
option is uses for to define multiple godown for a company.
1.
Click
on inventory information.
2.
Click
on Go down
3.
Click
on create.
4.
Name
– To enter the company godown name
1.
Click
on inventory information
2.
Click
on create.
Tips- Other procedure are same as normal
item entry.
1.
Click
on account voucher
2.
Click
on F9
3.
Party
account name – To enter the sundry creditor name.
4.
Purchase
ledger – To enter the item name.
5.
Go
down – To define the go down name for the item.
Tips- Other entries are same as normal
item entry.
Display-
Statement of inventory – Go down.
This option is used for to managed the
stock for its categories wise.
1.
Click
on inventory information
2.
Click
on stock categories
3.
Click
on create
4.
Name
– To enter the categories name
5.
Under
– To enter primary
1.
Click
on stock item
2.
Click
on create
3.
Name
– To enter the item name.
4.
Under
– To enter the primary
5.
Category
– To enter the item category.
è
Press
“Y” accept the item and “N” for cancel.
è
Other
implements are same as normal voucher entry.
Display: Display- Statements of inventory
– Categories
This
function gives a facilities to use name units for a single item. Ex- Tiger
biscuits.
1.
Click
on inventory information
2.
Click
on units of measure.
3.
Symbol
– To enter categories
4.
Formal
name – To enter full name (catoon)
1.
Click
on units of measure
2.
Click
on create
3.
Press
backspace
4.
Choose
compounds
5.
First
unit- To choose catoon
6.
Conversion
– To enter hundred (100)
7.
Second
unit – To enter piece
1.
Click
on F9
2.
Party
account name – To enter party account name.
3.
Purchase
ledger – To enter purchase account.
4.
Name
of item – To enter the item name item qty. and rate per individual (catoon).
Ex- Let 10.02 cat
(Tips) Press “Y” accepts the voucher and
“N” for cancel.
(Tips) When you want to purchase or sale
the catoon to enter the round figure ex- 5 catoon.
(Tips) If you want to sale or purchase
with piece
Ex- 0.5 (i.e. 5 pieces)
Same Configuration for sale voucher
Q- 1 tin 2 ltr. 1Ltr= 1000ml
but to sale 1 ltr.850ml
1.
1st
open more company
2.
Click
on company information
3.
Click
on create Group Company.
4.
Name-
To enter the Group Company name.
5.
Mailing
name – To enter the corresponding name of group company.
6.
Address
– To enter the corresponding address of group company.
7.
State-
To enter the sale of group company.
8.
Pincode-
To enter the postal index of group company.
9.
E-mail
address- To enter the electronic address of group company.
10. Use Indian Vat-
“Yes” (If applicable)
11. Local sale Tax
No – To enter the sale tax no which is provided by the sale tax department of
state Govt.
12. Inter state sale
tax no – To enter the sale tax no. which is provided by the sale tax department
of center Govt.
13. Income Tax No-
To enter income tax no such as pan (Permanent account No).
14. Member – To
enter company member name.
In
Orissa three types of VAT are available.
1.
4%
(2) 12.5% (3) 1%
12.5% - Foods, many types of food
material etc.
1% - Education (School, College, Office
Material etc.
1.
At
the time of company creation state name and pin code most be essential.
2.
Use
Indian VAT (Yes)
3.
Applicable
form – To enter the date of vat.
Tips- Press “Y” accepts the company and
“N” for cancel.
Use in Vat returns (Yes)
Vat tax class- Purchase 4%
1.
Press “Y” accept the voucher and “N’ for cancel.
2. Same entry as sale ledger.
Under
– To enter duties and taxes
Type
of duties- To enter VAT.
Vat
Tax class- To enter input vat at rate of 4%
(Tips) Press “Y” for accept the ledger
and “N” for cancel.
Under
– To enter duties and taxes
Type
of date – To enter VAT.
Vat
Tax class – To enter output vat at rate of 4% let
(Tips) Press “Y” for accept the ledger
and “N” for cancel.
Party Account name – To enter the party
name.
Current balance – To display the current
balance of active party.
Purchase ledger – To enter purchase
Vat/ Tax class – To enter purchase (4%)
Name of item – To enter the item name.
Qty. - To enter the item qty. and rate
per individual.
Amount – The amount will be calculated
automatic
Purchase Tax – It calculated the amount
vat automatic.
Display the VAT statement:
1.
Click
on display
2.
Click
on Vat reports
3.
Click
on Vat computation
(Tips) After complete the all above
procedure the vat statement will be display on the screen.
It
is used for to print all the existing statement.
1.
Click
on multiple account printing
2.
Click
on account books
3.
Click
on ledger.
4.
Choose
the ledger name and then click enter
5.
From
– To enter the beginning date of report.
6.
End
– To enter the end date of report.
7.
Style
of report – To enter normal ledger.
To
enter all voucher.
Formats – To enter details.
Show bill wises details also (Y)
Show inventory details also (Y)
Show narration also (Y)
Input opining balance (Y)
Method of balancing – To enter daily,
monthly weekly or yearly.
Page nos – To Change page no format.
Pre printed – To set paper format.
Print Format- This option is used for to
set the printing categories.
Copies – How many copies we want to
print.
Select printer – To set the printer.
1.
Click
on account information
2.
Click
on ledger
3.
Click
on Alter.
4.
Select
the ledger and open it.
Tips- Press (Alt + D) the delete the
ledger.
1.
Click
on display.
2.
Click
on account books
3.
Click
on ledger and open the voucher.
Tips – Press (Alt + D) To delete it.
1.
1st
click on my computer
2.
Then
click on drive “C”
3.
Tally
4.
Select
all
5.
Yes
6.
Clear
the tally folder.
1.
Balance
Sheet : To display the statement if active company such as capital account loans
liabilities, current liabilities , current assets and profit and loss
statement.
2.
Profit
and loss account – To display the profit and loss statement of active company.
3.
Stock
Summery – The display the item wise stock details with displaying monthly
statistics.
4.
Ratio
analysis – Display all statement of principal group and principal ration.
5.
Display
– Try balance – To display the statement about current liabilities current
assets, sales account and purchase account.
Cash and bank books – To display cash/
bank statement of active company.
Ledger – To display the statement of
individual ledger.
Group summery – To display the Group
wise account details.
Group voucher – To display the group
wise voucher details.
Sales resister – It is used for display
the sale statement of active company.
Purchase resister – If to display the
purchase statement with monthly statistics.
Out standing – To display the statement
of reliable amount and payable amount.
Ledger – To display the ledger wise
account statement such as sundry creditor and sundry debtor.
Group – To display the account statement
such as sundry creditor and sundry debtor.
Statistics – To display the account
statistics of active company.
Stock item – To display the item wise
the stock details with displaying outword qty., in word qty. and closing
balance.
Group summery – To display the group
wise item statement.
Stock Group analysis – To display the
group wise item details with inword qty value and effective rate.
Ageing analysis – To display to stock
statement with day wise.
Stock Transfer – To display the details
of stock journal.
Physical stock resister – To display the
statement of physical stock.
Go down – To display the stock item
details with go down wise.
Categories – To display the categories
wise the item wise.
Stock query – To display the individual
item details such as name, closing balance, cost price closing value, saling
value, go down, qty. etc.
Reorder status – This option use for to
display the closing stock and net available.
Cash flow – To display the statement of
inflow, out flow and net flow.
Funds flow – This option used for to
display the closing balance.
Day book – It is used for to display the
current day of transaction or existing day of transaction.
List of account – To display the account
details of active company.
Negative stock – To display all the
negative stock balance of active company.
Negative ledger – To display all the
negative ledger balance of active company.
Over due reliable – To display all the
pending amount of sundry which are over to mode.
Over due payable – To display all the
pending amount of sundry creditor which are over due mode.
Memorandum voucher – Display all the
memorandum voucher details.
Select company- To active an existing
company.
Shut company- To close the active
company.
Create company- To create a new company.
Alter – To edit or modify the company.
Change tally vault – To change the tally
vault password.
Split company Data – To divide the
company data from a specific data.
Back up – To create a duplicate copy of
active company.
Restore – To retrieve the backup company
data towards current location.
Quit- To close the tally.
Licensing – It is used for to display
all the function and features of active company.
General – To change all the internal
configuration for country details style of name style of date configuration of
no and other options.
Assets and inventory information – To
change internal configuration account master and inventory master.
Voucher entry – This option is used for
to change all internal configuration for account voucher and Inventory voucher.
Invoice order entry – This option is
used for to charge to set the configuration for invoice delivery notes and
orders.
Printing – To set the printing
configuration for general, payment voucher, receive voucher contra voucher,
debit/credit note, sale transaction purchase transaction etc.
Proxy configuration – This option is
used for to set the proxy configuration for tally in through internet.
This option is used for to display about
tally audit.
At
the time of company creation active the option use security control (Yes)
1.
Press
“Y” accept the feauchers and “N” for cancel
2.
After
complete the all above procedure the tally audit feaucher, display the audit
control statement of active company.
Display the tally audit statement:
1.
Click
on display
2.
Click
on statements of account.
3.
Click
on tally audit.
Tally audit statement divided into two
types (a) Voucher (b) Ledger
To
display all the voucher audit statement with displaying debit amount and credit
amount.
To
display all the ledger audit statement with displaying identification number.
C Programing
What is C?
C is a
procedural programming language initially developed by Dennis Ritchie in the
year 1972 at Bell Laboratories of AT&T Labs. It was mainly developed as a
system programming language to write the UNIX operating system.
The main
features of the C language include:
·
General Purpose and Portable
·
Low-level Memory Access
·
Fast Speed
·
Clean Syntax
These
features make the C language suitable for system programming like an operating
system or compiler development.
Why Should We Learn C?
Many later
languages have borrowed syntax/features directly or indirectly from the C
language. Like syntax of Java, PHP, JavaScript, and many other languages are
mainly based on the C language. C++ is nearly a superset of C language (Only a
few programs may compile in C, but not in C++).
So, if
a person learns C programming first, it will help him to learn any modern
programming language as well. As learning C help to understand a lot of the
underlying architecture of the operating system. Like pointers, working with
memory locations, etc.
Get Started
with C Learn C
fundamentals and advanced concepts, then solve practical problems right in your
browser window with Educative interactive skill path Become a C
Programmer. Sign up at Educative.io with the
code GEEKS10 to save 10% on your subscription.
Difference Between C and C++
C++ was created to add the OOPs concept into C language so they
both have very similar syntax but both are a bit different from each other.
Following are some main differences between C and C++ Programming language.
·
C++ supports OOPs paradigm
while C only have procedural concept of programming.
·
C++ have exception handling
capabilities. In C, we have to resolve manually.
·
There are no references in C.
There are many more differences between C and C++ which are
discussed here: Difference
between C and C++
Beginning with C Programming
Writing the
First Program in C
The following code is one of the simplest C programs that will
help us the basic syntax structure of a C program.
Structure of
the C program
After the above discussion, we can formally assess the structure
of a C program. By structure, it is meant that any program can be written in
this structure only. Writing a C program in any other structure will hence lead
to a Compilation Error. The structure of a C program is as follows:
Components of a C Program:
1. Header
Files Inclusion – Line 1 [#include <stdio.h>]
The
first and foremost component is the inclusion of the Header files in a C
program. A header file is a file with extension .h which contains C
function declarations and macro definitions to be shared between several source
files. All lines that start with # are processed by a preprocessor
which is a program invoked by the compiler. In the above example, the
preprocessor copies the preprocessed code of stdio.h to our file. The .h files
are called header
files
in C.
Some of the C Header files:
stddef.h – Defines several
useful types and macros.
stdint.h – Defines exact width
integer types.
stdio.h – Defines core input
and output functions
stdlib.h – Defines numeric
conversion functions, pseudo-random number generator, and memory allocation
string.h – Defines string
handling functions
math.h – Defines common
mathematical functions.
2. Main
Method Declaration – Line 2 [int main()]
The next part of a C program is to declare the main() function. It
is the entry point of a C program and the execution typically begins with the
first line of the main(). The empty brackets indicate that the main doesn’t
take any parameter (See this for more details). The int that was written before the main
indicates the return type of main(). The value returned by the main indicates
the status of program termination. See this post for more details on the return type.
3. Body of
Main Method – Line 3 to Line 6 [enclosed in {}]
The body of a function in the C program refers to statements that
are a part of that function. It can be anything like manipulations, searching,
sorting, printing, etc. A pair of curly brackets define the body of a function.
All functions must start and end with curly brackets.
4. Statement
– Line 4 [printf(“Hello World”);]
Statements are the instructions given to the compiler. In C, a
statement is always terminated by a semicolon (;). In
this particular case, we use printf() function to instruct the compiler to
display “Hello World” text on the screen.
5. Return
Statement – Line 5 [return 0;]
The last part of any C function is the return statement. The
return statement refers to the return values from a function. This return
statement and return value depend upon the return type of the function. The
return statement in our program returns the value from main(). The returned
value may be used by an operating system to know the termination status of your
program. The value 0 typically means successful termination.
How to Execute the Above Program?
In order to execute the above program, we need to first compile it
using a compiler and then we can run the generated executable. There are online
IDEs available for free like GeeksforGeeksIDE that can be used to start development in C without installing a
compiler.
1.
Windows: There are many free IDEs available for developing programs
in C like Code Blocks and Dev.-CPP. IDEs provide us with an
environment to develop code, compile it and finally execute it. We strongly
recommend Code Blocks.
2.
Linux: GCC compiler comes bundled with Linux which compiles C
programs and generates executable for us to run. Cod e Blocks can also be used with Linux.
3.
macros: macOS already has a built-in
text editor where you can just simply write the code and save it with a “.c”
extension.
Application of C
·
Operating systems: C is widely
used for developing operating systems such as Unix, Linux, and Windows.
·
Embedded systems: C is a
popular language for developing embedded systems such as microcontrollers,
microprocessors, and other electronic devices.
·
System software: C is used for
developing system software such as device drivers, compilers, and assemblers.
·
Networking: C is widely used
for developing networking applications such as web servers, network protocols,
and network drivers.
·
Database systems: C is used for
developing database systems such as Oracle, MySQL, and PostgreSQL.
·
Gaming: C is often used for
developing computer games due to its ability to handle low-level hardware interactions.
·
Artificial Intelligence: C is
used for developing artificial intelligence and machine learning applications
such as neural networks and deep learning algorithms.
·
Scientific applications: C is
used for developing scientific applications such as simulation software and
numerical analysis tools.
· Financial applications: C is used for developing financial applications such as stock market analysis and trading systems.
fgets() and gets() in C language
For reading a string value with spaces,
we can use either gets() or fgets() in C programming language. Here, we will
see what is the difference between gets() and fgets().
fgets()
The fgets() reads a line from the specified stream and stores it into the
string pointed to by str. It stops when either (n-1) characters are read, the
newline character is read, or the end-of-file is reached, whichever comes
first.
Syntax
char *fgets (char *str, int n, FILE *stream);
Parameters
·
str: Pointer to an array
of chars where the string read is copied.
·
n: Maximum number of
characters to be copied into str (including the terminating null character).
·
*stream: Pointer to a FILE
object that identifies an input stream.
Note: stdin can
be used as argument to read from the standard input.
Return Value
·
The fgets() function returns a
pointer to the string where the input is stored.
Parameter Passing Techniques in C
In C, there are different ways in which parameter data can be passed into and out of methods and functions. Let us assume that a function B() is called from another function A(). In this case, A is called the “caller function” and B is called the “called function or callee function”. Also, the arguments which A sends to B are called actual arguments and the parameters of B are called formal arguments.
Terminology
·
Formal
Parameter: A
variable and its type as it appears in the prototype of the function or method.
·
Actual
Parameter: The
variable or expression corresponding to a formal parameter that appears in the
function or method call in the calling environment.
·
Modes:
- IN: Passes info from caller to the callee.
- OUT: Callee writes values in the caller.
- IN/OUT: The caller tells the callee the value of the
variable, which the callee may update.
Methods of Parameter Passing in C
There are two ways in which we can pass the parameters to the function in
C:
1. Pass By Value
This method uses in-mode semantics.
Changes made to formal parameters do not get transmitted back to the caller.
Any modifications to the formal parameter variable inside the called function
or method affect only the separate storage location and will not be reflected
in the actual parameter in the calling environment. This method is also called
Function Prototype in C
The C
function prototype is a statement that tells the compiler about the function’s
name, its return type, numbers and data types of its parameters. By using this
information, the compiler cross-checks function parameters and their data type
with function definition and function call.
Function prototype
works like a function declaration where it is necessary where the function
reference or call is present before the function definition but optional if the
function definition is present before the function call in the program.
Syntax
return_type
function_name(parameter_list);
where,
·
return_type: It is
the data type of the value that the function returns. It can be any data type
int, float, void, etc. If the function does not return anything, void is used
as the return type.
·
function_name: It is the identifier of the function. Use appropriate
names for the functions that specify the purpose of the function.
·
parameter_list: It is the list of parameters that a function expects in
parentheses. A parameter consists of its data type and name. If we don’t want
to pass any parameter, we can leave the parentheses empty.
What is the purpose of a function prototype?
The Function prototype is necessary to serve the following
purposes:
1.
Function prototype tells the return
type of the data that the function will return.
2.
Function prototype tells the number
of arguments passed to the function.
3.
Function prototype tells the data
types of each of the passed arguments.
4.
Also, the function prototype tells
the order in which the arguments are passed to the function.
Therefore essentially, the function prototype specifies the input/output
interface to the function i.e. what to give to the function and what to expect
from the function.
Note: The prototype of a
function is also called the signature of the function.
What if one doesn’t
specify the function prototype?
If one doesn’t specify the function prototype, the behavior is specific
to the C standard (either C90 or C99) that the compilers implement. Up to the
C90 standard, C compilers assumed the return type of the omitted function
prototype as int. And this assumption on the compiler side may lead to
unspecified program behavior.
Later C99 standard specified that compilers could no longer assume the
return type as int. Therefore, C99 became more restricted in type checking of
function prototypes. But to make C99 standard backward compatible, in practice,
compilers throw the warning saying that the return type is assumed as int. But
they go ahead with compilation. Thus, it becomes the responsibility of
programmers to make sure that the assumed function prototype and the actual
function type match.
To avoid all these implementation specifics matching C standards, it is
best to have a function prototype.
C Function Arguments and Function Return
Values
A function in C can be called either with arguments or without arguments. These functions may or may not return values to the calling functions. All C functions can be called either with arguments or without arguments in a C program. Also, they may or may not return any values. Hence the function
1.
Hallo world: -
#include<stdio.h>
Void main ()
{
printf("hallo
world");
}
Output: - hallo world
2. Addition: -
#include<stdio.h>
Void main ()
{
Int
a=1000;
Int
b=6000;
Int
c=a+b;
Printf("addition
of %d+%d=%d", a,b,c);
}
Output: -1000+6000=7000
3.
Multiplication: -
#include <stdio.h>
int main()
{
int
num1, num2, sum;
printf("Enter two numbers: ");
scanf("%d %d", &num1,
&num2);
sum = num1 * num2;
printf("mul:
%d", sum);
return 0;
}
Output: -10*10=100
4.
Subtraction: -
#include <stdio.h>
Int main()
{
Int
num1, num2, sum;
printf("Enter two numbers: ");
scanf("%d %d", &num1, &num2);
Sum
= num1 - num2;
Printf("mul: %d", sum);
Return 0;
}
Output: -20-5=15
5.
Ball game: -
#include <stdio.h>
#include <stdlib.h>
#include <time.h>
int main()
{
int
position = 0;
srand(time(0));
while (1)
{
int move = rand() % 3 - 1;
position += move;
if (position < 0)
{
printf("Oops! The ball fell off the track. Game Over!\n");
break;
}
printf("The ball is at position: %d\n", position);
if (position >= 10) {
printf("Congratulations! You won the game!\n");
break; } } Return 0; }
6.
Year:-
#include <stdio.h>
int main()
{
int
year = 2024;
int
month, day;
for
(month = 1; month <= 12; month++) {
printf("Month: %d\n", month);
printf("Sun Mon Tue Wed Thu Fri Sat\n");
// Code to generate the calendar for each month goes here (comment)
printf("\n");
}
return 0;
}
7.
Day:-
#include<stdio.h>
#include<conio.h>
void main()
{
int
i;
clrscr();
printf("enter
the week day :");
scanf("%d",&i);
switch(i);
{
caes
1:
printf("Monday");
break;
caes
2:
printf("Tuesday");
break;
caes
3:
printf("Wednesday");
break;
caes
4:
printf("Thrusday");
break;
caes
5:
printf("Friday");
break;
caes
6:
printf("Saturday");
break;
default;
printf("Put
wrong number :");
}
}
Date, month, year: -
#include <iostream>
#include <ctime>
Int main()
{
Time
now = time(0);
tm
*ltm = localtime(&now);
int
month = 1 + ltm->tm_mon;
int
date = ltm->tm_mday;
int
year = 1900 + ltm->tm_year;
std::cout << "Month: " << month <<
std::endl;
std::cout << "Date: " << date << std::endl;
std::cout << "Year: " << year << std::endl;
Return 0;
}
Output:-7/12/2024
FORMATTED INPUT-OUTPUT
Data can be entered &displayed in a
particular format. Through format specifications, better presentation of result
can be obtained.
Variations in output for integer & floate:
#include<stdio.h>
Int main()
{
printf(“Case 1:%6d/n”,9876 );
/* prints the number right justified within 6
columns */
printf(“case 2:%3d/n”,9876);
/* prints the number right justified to 3
columns but, there are 4 digits so number is not right justified */
}
Example:
C
#include <stdio.h>
int main() {
int a = 10;
printf("%d", a);
return 0;
}
Output
10
Prototype of a function in C is as
below:
Call by Value
Call
by value in C is where in the arguments we pass value and that value can be
used in function for performing the operation. Values passed in the function
are stored in temporary memory so the changes performed in the function don’t
affect the actual value of the variable passed.
Example: C
// C Program to implement
// Call by value
#include <stdio.h>
// Call by value
int sum(int x, int y)
{
int c;
c = x + y;
// Integer value
retured
return c;
}
// Driver Code
int main()
{
// Integer Declared
int a = 3, b = 2;
// Function Called
int c = sum(a, b);
printf("Sum of %d and %d :
%d", a, b, c);
return 0;
}
Output
Sum of 3 and 2 : 5
Call by Reference
Call by reference is the method in C where we call the function with the
passing address as arguments. We pass the address of the memory blocks which
can be further stored in a pointer variable that can be used in the function.
Now, changes performed in the values inside the function can be directly
reflected in the main memory.
Example: C
// C Program to implement
// Call by reference
#include <stdio.h>
// Call by reference
void
swap(int*
x, int* y)
{
int
temp = *x;
*x = *y;
*y = temp;
}
// Driver
Code
int
main()
{
// Declaring Integer
int
x = 1, y = 5;
printf("Before Swapping:
x:%d , y:%d\n", x, y);
//
Calling the function
swap(&x, &y);
printf("After Swapping: x:%d
, y:%d\n", x, y);
return
0;
}
Output
Before Swapping: x:1, y:5
After Swapping: x:5, y:1
Types of Function According to Arguments and Return Value
Functions can be differentiated into 4 types according to the arguments
passed and value returns these are:
1.
Function with arguments and return
value
2.
Function with arguments and no return
value
3.
Function with no arguments and with
return value
4.
Function with no arguments and no
return value
1. Function
with arguments and return value
Syntax:
Function declaration: int function (int);
Function call: function (x);
Function definition:
int function (int x)
{
statements;
return x;
}
Example: C
// C code for function with arguments
// and return value
#include <stdio.h>
#include <string.h>
int
function(int, int[]);
int
main()
{
int
i, a = 20;
int
arr[5] = { 10, 20, 30, 40, 50 };
a
= function(a, &arr[0]);
printf("value
of a is %d\n", a);
for
(i = 0; i < 5; i++) {
printf("value
of arr[%d] is %d\n", i, arr[i]);
}
return
0;
}
int
function(int
a, int*
arr)
{
int
i;
a = a + 20;
arr[0]
= arr[0] + 50;
arr[1] = arr[1] + 50;
arr[2] =
arr[2] + 50;
arr[3] =
arr[3] + 50;
arr[4] = arr[4] + 50;
return
a;
}
Output
value of a is 40
value of arr[0] is 60
value of arr[1] is 70
value of arr[2] is 80
value of arr[3] is 90
value of arr[4] is 100
2. Function
with arguments but no return value
When a function has arguments, it receives any data from the calling
function but it returns no values. These are void functions with no return
values.
Syntax:
Function declaration : void function ( int );
Function call : function( x );
Function definition:
void function( int x )
{
statements;
}
Example: C
// C code for function
// with argument but no return value
#include <stdio.h>
void
function(int, int[], char[]);
int
main()
{
int
a = 20;
int
ar[5] = { 10, 20, 30, 40, 50 };
char
str[30] = "geeksforgeeks";
//
function call
function(a, &ar[0],
&str[0]);
return
0;
}
void
function(int
a, int* ar,
char* str)
{
int
i;
printf("value of a is
%d\n\n", a);
for
(i = 0; i < 5; i++) {
printf("value
of ar[%d] is %d\n", i, ar[i]);
}
printf("\nvalue
of str is %s\n", str);
}
Output
value of a is 20
value of ar[0] is 10
value of ar[1] is 20
value of ar[2] is 30
value of ar[3] is 40
value of ar[4] is 50
value of str is geeksforgeeks
3. Function
with no argument and no return value
When a function has no arguments, it does not receive any data from the
calling function. Similarly, when it does not return a value, the calling
function does not receive any data from the called function.
Syntax:
Function declaration : void function();
Function call : function();
Function definition :
void function()
{
statements;
}
Example: C
// C code for function with no
// arguments and no return value
#include <stdio.h>
void
value(void);
void
main() {
value();
}
void
value(void)
{
float
year = 1, period = 5, amount =
5000,
inrate
= 0.12;
float
sum;
sum = amount;
while
(year <= period) {
sum = sum
* (1 + inrate);
year =
year + 1;
}
printf(" The total amount is
:%f", sum);
}
Output
The total amount is :8811.708984
4. Function
with no arguments but returns a value
There could be occasions where we may need to design functions that may
not take any arguments but returns a value to the calling function. An example
of this is getchar function which has no parameters but it returns an integer
and integer-type data that represents a character.
Syntax:
Function declaration: int function ();
Function call: function();
Function definition:
int function ()
{
statements;
return x;
}
Example: C
// C code for function with no arguments
// but have return value
#include <math.h>
#include <stdio.h>
int
sum();
int
main()
{
int
num;
num = sum();
printf("Sum of two given
values = %d", num);
return
0;
}
int
sum()
{
int
a = 50, b = 80, sum;
sum = sqrt(a) + sqrt(b);
return
sum;
}
Output
Sum of two given values = 16
How can I return multiple values from a
function?
We all know that a function in C can return only one value. So how do we achieve the purpose of returning multiple values.
Well, first take a look at the declaration of a function.
intfoo
(int
arg1, int
arg2);
So we can notice here that our interface to the function is through
arguments and return value only. (Unless we talk about modifying the globals
inside the function)
Let us take a deeper look…Even though a function can return only one
value but that value can be of pointer type. That’s correct, now you’re
speculating right!
We can declare the function such that, it returns a structure type user defined
variable or a pointer to it . And by the property of a structure, we know that
a structure in C can hold multiple values of asymmetrical types (i.e. one int
variable, four char variables, two float variables and so on…)
If we want the function to return multiple values of same data types, we
could return the pointer to array of that data types.
We can also make the function return multiple values by using the
arguments of the function. How? By providing the pointers as arguments.
Usually, when a function needs to return several values, we use one
pointer in return instead of several pointers as arguments.
Please see How
to return multiple values from a function in C or C++? for more details.
How to return multiple values from a function
in C or C++?
New programmers are usually in the search of ways to return multiple
values from a function. Unfortunately, C and C++ do not allow this directly.
But fortunately, with a little bit of clever programming, we can easily achieve
this. Below are the methods to return multiple
values from a function in C:
1.
By using pointers.
2.
By using structures.
3.
By using Arrays.
Example: Consider an example
where the task is to find the greater and smaller of two distinct numbers. We
could write multiple functions. The main problem is the trouble of calling more
than one functions since we need to return multiple values and of course,
having more number of lines of code to be typed.
1.
Returning
multiple values Using pointers: Pass the argument with their
address and make changes in their value using pointer. So that the values get
changed into the original argument.
·
C++
·
C
// Modified program using pointers
#include <iostream>
using
namespace
std;
// add is
the short name for address
void
compare(int
a, int
b, int* add_great, int* add_small)
{
if
(a > b) {
//
a is stored in the address pointed
// by the
pointer variable *add_great
*add_great
= a;
*add_small
= b;
}
else
{
*add_great
= b;
*add_small
= a;
}
}
// Driver
code
int
main()
{
int
great, small, x, y;
cout
<< "Enter two numbers: \n";
cin >> x >> y;
//
The last two arguments are passed
// by giving addresses of memory
locations
compare(x, y, &great,
&small);
cout << "\nThe greater
number is "
<<
great << " and the smaller number is "
<< small;
return
0;
}
// This
code is contributed by sarajadhav12052009
Output:
Enter two numbers:
5 8
The greater number is 8 and the smaller number is 5
1.
Returning
multiple values using structures: As the structure is a user-defined
datatype. The idea is to define a structure with two integer variables and
store the greater and smaller values into those variables, then use the values
of that structure.
C
// Modified program using structures
#include <stdio.h>
struct
greaterSmaller
{
int
greater, smaller;
};
typedef
struct
greaterSmaller Struct;
Struct
findGreaterSmaller(int
a, int
b)
{
Struct s;
if
(a > b) {
s.greater
= a;
s.smaller
= b;
}
else
{
s.greater
= b;
s.smaller
= a;
}
return
s;
}
// Driver
code
int
main()
{
int
x, y;
Struct result;
printf("Enter
two numbers: \n");
scanf("%d%d", &x,
&y);
//
The last two arguments are passed
// by giving addresses of memory
locations
result = findGreaterSmaller(x,
y);
printf("\nThe greater number
is %d and the"
"smaller
number is %d",
result.greater,
result.smaller);
return
0;
}
Output:
Enter two numbers:
5 8
The greater number is 8 and the smaller number is 5.
1.
Returning
multiple values using an array (Works only when returned items are of same
types): When
an array is passed as an argument then its base address is passed to the
function so whatever changes made to the copy of the array, it is changed in
the original array. Below is the program to return multiple values using array
i.e. store greater value at arr[0] and smaller at arr[1].
·
C++
·
C
// Modified program using array
#include <iostream>
using
namespace
std;
// Store the greater element at 0th
index
void
find Greater
Smaller (int
a, int
b, int
arr[])
{
//
Store the greater element at
// 0th index of the array
if
(a > b) {
arr[0] =
a;
arr[1] =
b;
}
else
{
arr[0] =
b;
arr[1] =
a;
}
}
// Driver
code
int
main()
{
int
x, y;
int
arr[2];
cout
<< "Enter two numbers: \n";
cin >> x >> y;
findGreaterSmaller(x,
y, arr);
cout
<< "\nThe greater number is "
<<
arr[0] << " and the "
"smaller
number is "
<<
arr[1];
return
0;
}
// This code is contributed by
sarajadhav12052009
Output:
Enter two numbers:
5 8
The greater number is 8 and the smaller number is 5
C++ Only Methods
1.
Returning
multiple values Using References: We use references in C++ to store returned
values.
·
CPP
// Modified program using References in C++
#include <stdio.h>
void
compare(int
a, int
b, int
&add_great, int
&add_small)
{
if
(a > b) {
add_great
= a;
add_small
= b;
}
else
{
add_great
= b;
add_small
= a;
}
}
// Driver code
int
main()
{
int
great, small, x, y;
printf("Enter
two numbers: \n");
scanf("%d%d", &x,
&y);
//
The last two arguments are passed
// by giving addresses of memory
locations
compare(x, y, great, small);
printf("\nThe greater number
is %d and the"
"smaller
number is %d",
great,
small);
return
0;
}
Output:
Enter two numbers:
5 8
The greater number is 8 and the smaller number is 5
1.
Returning
multiple values using Class and Object: The idea is similar to structures. We
create a class with two integer variables and store the greater and smaller
values into those variables, then use the values of that structure.
·
CPP
// Modified program using class
#include <stdio.h>
class
GreaterSmaller {
public:
int
greater, smaller;
};
GreaterSmaller
findGreaterSmaller(int
a, int
b)
{
GreaterSmaller s;
if
(a > b) {
s.greater
= a;
s.smaller = b;
}
else
{
s.greater
= b;
s.smaller = a;
}
return
s;
}
// Driver
code
int
main()
{
int
x, y;
GreaterSmaller result;
printf("Enter
two numbers: \n");
scanf("%d%d", &x,
&y);
//
The last two arguments are passed
// by giving addresses of memory
locations
result = findGreaterSmaller(x,
y);
printf("\nThe greater number
is %d and the"
"smaller
number is %d",
result.greater,
result.smaller);
return
0;
}
Output:
Enter two numbers:
5 8
The greater number is 8 and the smaller number is 5.
1.
Returning
multiple values using STL tuple: The idea is similar to structures. We
create a tuple with two integer variables and return the tuple, and then inside
main function we use tie function to assign values to min and max that is returned
by the function.
CPP
// Modified program using C++ STL tuple
#include<iostream>
#include<tuple>
using
namespace
std;
tuple <int, int>
findGreaterSmaller(int
a, int
b)
{
if
(a < b) {
return
make_tuple(a, b);
}
else
{
return
make_tuple(b, a);
}
}
// Driver code
int
main()
{
int
x = 5, y= 8;
int
max, min;
tie(min, max) =
findGreaterSmaller(x, y);
printf("The greater number is %d and the "
"smaller
number is %d",
max,
min);
return
0;
}
// This
article is contributed by Blinkii
Output:
The greater number is 8 and the smaller number is 5
How can I return multiple values from a
function?
New programmers are usually in the search of ways to return multiple
values from a function. Unfortunately, C and C++ do not allow this directly.
But fortunately, with a little bit of clever programming, we can easily achieve
this. Below are the methods to return multiple
values from a function in C:
1.
By using pointers.
2.
By using structures.
3.
By using Arrays.
Example: Consider an example
where the task is to find the greater and smaller of two distinct numbers. We
could write multiple functions. The main problem is the trouble of calling more
than one functions since we need to return multiple values and of course,
having more number of lines of code to be typed.
1.
Returning
multiple values Using pointers: Pass the argument with their
address and make changes in their value using pointer. So that the values get
changed into the original argument.
C++
// Modified program using pointers
#include <iostream>
using
namespace
std;
// add is the short name for
address
void
compare(int
a, int
b, int* add_great, int* add_small)
{
if
(a > b) {
//
a is stored in the address pointed
// by the
pointer variable *add_great
*add_great
= a;
*add_small
= b;
}
else
{
*add_great
= b;
*add_small
= a;
}
}
// Driver code
int
main()
{
int
great, small, x, y;
cout
<< "Enter two numbers: \n";
cin >> x >> y;
// The last
two arguments are passed
// by giving addresses of memory
locations
compare(x, y, &great,
&small);
cout << "\nThe greater
number is "
<<
great << " and the smaller number is "
<< small;
return
0;
}
// This
code is contributed by sarajadhav12052009
Output:
Enter two numbers:
5 8
The greater number is 8 and the smaller number is 5
1.
Returning
multiple values using structures: As the structure is a user-defined
datatype. The idea is to define a structure with two integer variables and
store the greater and smaller values into those variables, then use the values
of that structure.
C
// Modified program using structures
#include <stdio.h>
struct
greaterSmaller
{
int
greater, smaller;
};
typedef
struct
greaterSmaller Struct;
Struct findGreaterSmaller(int
a, int
b)
{
Struct s;
if
(a > b) {
s.greater
= a;
s.smaller
= b;
}
else
{
s.greater
= b;
s.smaller
= a;
}
return
s;
}
// Driver code
int
main()
{
int
x, y;
Struct result;
printf("Enter
two numbers: \n");
scanf("%d%d", &x,
&y);
// The last
two arguments are passed
// by giving addresses of memory
locations
result = findGreaterSmaller(x,
y);
printf("\nThe greater number
is %d and the"
"smaller
number is %d",
result.greater,
result.smaller);
return
0;
}
Output:
Enter two numbers:
5 8
The greater number is 8 and the smaller number is 5.
1.
Returning
multiple values using an array (Works only when returned items are of same
types): When
an array is passed as an argument then its base address is passed to the
function so whatever changes made to the copy of the array, it is changed in
the original array. Below is the program to return multiple values using array
i.e. store greater value at arr[0] and smaller at arr[1]
C++
// Modified program using array
#include <iostream>
using
namespace
std;
// Store
the greater element at 0th index
void
findGreaterSmaller(int
a, int
b, int
arr[])
{
//
Store the greater element at
// 0th index of the array
if
(a > b) {
arr[0] =
a;
arr[1] =
b;
}
else
{
arr[0] =
b;
arr[1] =
a;
}
}
// Driver
code
int
main()
{
int
x, y;
int
arr[2];
cout
<< "Enter two numbers: \n";
cin >> x >> y;
findGreaterSmaller(x,
y, arr);
cout
<< "\nThe greater number is "
<<
arr[0] << " and the "
"smaller
number is "
<<
arr[1];
return
0;
}
// This
code is contributed by sarajadhav12052009
Output:
Enter two numbers:
5 8
The greater number is 8 and the smaller number is 5
·
C++
Only Methods
1.
Returning
multiple values Using References: We use references in C++ to store returned
values.
·
CPP
// Modified program using References in C++
#include <stdio.h>
void
compare(int
a, int
b, int
&add_great, int
&add_small)
{
if
(a > b) {
add_great
= a;
add_small
= b;
}
else
{
add_great
= b;
add_small
= a;
}
}
// Driver
code
int
main()
{
int
great, small, x, y;
printf("Enter
two numbers: \n");
scanf("%d%d", &x,
&y);
//
The last two arguments are passed
// by giving addresses of memory
locations
compare(x, y, great, small);
printf("\nThe greater number
is %d and the"
"smaller
number is %d",
great,
small);
return
0;
}
Output:
Enter two numbers:
5 8
The greater number is 8 and the smaller number is 5
1.
Returning
multiple values using Class and Object: The idea is similar to structures. We
create a class with two integer variables and store the greater and smaller
values into those variables, then use the values of that structure.
·
CPP
// Modified program using class
#include <stdio.h>
class
GreaterSmaller
{
public:
int
greater, smaller;
};
GreaterSmaller
findGreaterSmaller(int
a, int
b)
{
GreaterSmaller s;
if
(a > b) {
s.greater
= a;
s.smaller = b;
}
else
{
s.greater
= b;
s.smaller = a;
}
return
s;
}
// Driver code
int
main()
{
int
x, y;
GreaterSmaller result;
printf("Enter
two numbers: \n");
scanf("%d%d", &x,
&y);
// The last two arguments are
passed
// by giving addresses of memory
locations
result = findGreaterSmaller(x,
y);
printf("\nThe greater number
is %d and the"
"smaller
number is %d",
result.greater,
result.smaller);
return
0;
}
Output:
Enter two numbers:
5 8
The greater number is 8 and the smaller number is 5
1.
Returning
multiple values using STL tuple: The idea is similar to structures. We
create a tuple with two integer variables and return the tuple, and then inside
main function we use tie function to assign values to min and max that is
returned by the function.
·
CPP
// Modified program using C++ STL tuple
#include<iostream>
#include<tuple>
using
namespace
std;
tuple
<int, int> findGreaterSmaller(int
a, int
b)
{
if
(a < b) {
return
make_tuple(a, b);
}
else
{
return
make_tuple(b, a);
}
}
// Driver
code
int
main()
{
int
x = 5, y=
8;
int
max, min;
tie(min,
max) = findGreaterSmaller(x, y);
printf("The greater number is %d and the "
"smaller
number is %d",
max,
min);
return
0;
}
// This
article is contributed by Blinkii
Output:
The greater number is 8 and the smaller number is 5.
No comments:
Post a Comment