Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                
0% found this document useful (0 votes)
68 views

Simple Problem

This document provides 5 simple C++ programming problems and their solutions. The problems include computing elasticity of demand, total cost/revenue/profit, diameter and circumference of a circle, slope of a line, and computing amount due and change for a customer. Each problem is presented with the required calculations and a short C++ program to perform the computations is provided as the solution.
Copyright
© Attribution Non-Commercial (BY-NC)
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)
68 views

Simple Problem

This document provides 5 simple C++ programming problems and their solutions. The problems include computing elasticity of demand, total cost/revenue/profit, diameter and circumference of a circle, slope of a line, and computing amount due and change for a customer. Each problem is presented with the required calculations and a short C++ program to perform the computations is provided as the solution.
Copyright
© Attribution Non-Commercial (BY-NC)
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/ 5

SIMPLE PROBLEM 1. Write a C++ program that will compute for the elasticity of demand.

Where:

Solution:
#include<iostream.h> int q1,q2,p1,p2,ed; int main() { cout<<"First Quantity:"; cin>>q1; cout<<"Second Quantity:"; cin>>q2; cout<<"First Price:"; cin>>p1; cout<<"Second Price:"; cin>>p2; ed= ((q1-q2)/q1)/((p1-p2)/p1); cout<<"The elasticity of demand is:"<<ed<<endl; system ("PAUSE"); } return 0;

2. Write a C++ program that will compute for the total cost, total revenue and profit. Where: Total Cost = Variable Cost + Fixed Cost Total Revenue = Quantity x Price Profit = Total Revenue Total Cost Solution: #include<iostream.h> int VC,FC,Q,pr,TR,TC,P; int main() { cout<<"Input cin>>VC; cout<<"Input cin>>FC; cout<<"Input cin>>Q; cout<<"Input cin>>pr; TC= VC+FC; TR=Q*pr; P=TR-TC; cout<<"The Total Cost is:"<<TC<<endl; cout<<"The Total Revenue is:"<<TR<<endl; cout<<"The Profit is:"<<P<<endl; system ("PAUSE"); } return 0;

Variable Cost:"; Fixed Cost:"; quantity:"; price of the product:";

3. Write a C++ program that will compute for the diameter and circumference of a circle. Where: Diameter = 2 x radius Circumference = diameter x pi Solution: #include<iostream.h> int r,d; float c; const float pi=3.14; int main() { cout<<"Input the radius:"; cin>>r; d=2*r; c=d*pi; cout<<"The diameter is:"<<d<<endl; cout<<"The dcircumference is:"<<c<<endl; system ("PAUSE"); } return 0;

4. Write a C++ program that will compute for the slope a line. Where: Slope = Solution: #include<iostream.h> int y1,y2,x1,x2,y,x; float m; int main() { cout<<"Input cin>>y1; cout<<"Input cin>y2; cout<<"Input cin>>x1; cout<<"Input cin>>x2; y=y1-y2; x=x1-x2; m=y/x; cout<<"The Slope is:"<<m<<endl; system ("PAUSE"); } return 0;

Y1:"; Y2:"; X1:"; X2:";

5. Write a C++ program that will compute for the amount due of customers and total change by giving the number of scan, print, layout and amount received. Where: 1 Scan = 15 1 print = 3 1 layout = 75 Solution: int main() { cout<<"Number of Scan:"; cin>>s; cout<<"Number of Print:"; cin>>p; cout<<"Number of Layout:"; cin>>l; cout<<"Amount received:"; cin>>ar; ts=s*15; tp=p*3; tl=l*75; ad=ts+tp+tl; tc=ar-ad; cout<<"The amount due is:"<<ad<<endl; cout<<"The total change is:"<<tc<<endl; system ("PAUSE"); } return 0;

You might also like