- Data Structure
- Networking
- RDBMS
- Operating System
- Java
- MS Excel
- iOS
- HTML
- CSS
- Android
- Python
- C Programming
- C++
- C#
- MongoDB
- MySQL
- Javascript
- PHP
- Physics
- Chemistry
- Biology
- Mathematics
- English
- Economics
- Psychology
- Social Studies
- Fashion Studies
- Legal Studies
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
C++ program to calculate GST from original and net prices
Given with the original cost and net price as an input and the task is to calculate the GST percentage and display the result
GST stands for Goods and Service task. It is always included in the Net price of the product and before calculating the GST percentage we need to calculate GST amount and for that there are formulas available
Netprice = originalcost + GSTAmount
GSTAmount = Netprice – original_cost
GST_Percentage = (GSTAmount * 100)/ originalcost
GST % formula = (GSTAmount*100) / originalcost
Example
Input-: cost = 120.00 price = 150.00 Output-: GST amount is = 25.00 % Input-: price = 120.00 cost = 100.00 Output-: GST amount is = 20.00 %
Approach used in the given program is as follows −
- Take the input as net price and original cost
- Apply the formula given to calculate GST percentage
- Display the result
Algorithm
Start Step 1-> declare function to calculate GST float GST(float cost, float price) return (((price - cost) * 100) / cost) step 2-> In main() set float cost = 120 set float price = 150 call GST(cost, price) Stop
Example
Using c++ #include <iostream> using namespace std; //function to calculate GST float GST(float cost, float price) { return (((price - cost) * 100) / cost); } int main() { float cost = 120.00; float price = 150.00; cout << "GST amount is = "<<GST(cost, price)<<" % "; return 0; }
Output
IF WE RUN THE ABOVE CODE IT WILL GENERATE FOLLOWING OUTPUT
GST amount is = 25.00 %
Using C
Example
#include <stdio.h> //function to calculate GST float GST(float cost, float price) { return (((price - cost) * 100) / cost); } int main() { float cost = 120; float price = 150; float gst = GST(cost, price); printf("GST amount is : %.2f ",gst); return 0; }
Output
IF WE RUN THE ABOVE CODE IT WILL GENERATE FOLLOWING OUTPUT
GST amount is : 25.00
Advertisements