# Price Elasticity of Demand Program

Page 1 of 1

## 0 Replies - 495 Views - Last Post: 10 December 2005 - 05:17 PMRate Topic: //<![CDATA[ rating = new ipb.rating( 'topic_rate_', { url: 'https://www.dreamincode.net/forums/index.php?app=forums&module=ajax&section=topics&do=rateTopic&t=364153&amp;s=179593ffa0d4a8649739cb7140cec6eb&md5check=' + ipb.vars['secure_hash'], cur_rating: 0, rated: 0, allow_rate: 0, multi_rate: 1, show_rate_text: true } ); //]]>

### #1 Kevin Beecher

Reputation: 0
• Posts: 0
• Joined: 10-December 05

# Price Elasticity of Demand Program

Posted 10 December 2005 - 05:17 PM

Description: just enter the original quantity demanded, then the new, then enter your original price, then the new price.This is my first 'good program' as I have just started C, what this program does is it works out how Elastic / Inelastic a Demand Curve (this relates to economics), Enjoy!
```#include<stdio.h>
#include<conio.h>
#include<math.h>

int main (int args,char ** argc){
printf("***Price Elasticity of Demand Program v2.5***");
printf("Developed by Kevin Beecher (c)");
printf("n_____________________________________________nnn");
//declaration of variables
double nQ1,nQ2,nP1,nP2,nChgQ,nChgP,nSec1,nSec2,nResult1,nResult2,nElasticity;
char quit;
do {
printf("Quantity 1 = ");scanf("%lf",&nQ1);
printf("nQuantity 2 = ");scanf("%lf",&nQ2);
printf("nnPrice 1 = ");scanf("%lf",&nP1);
printf("nPrice 2 = ");scanf("%lf",&nP2);

//output
nChgQ = nQ2-nQ1;
nChgP = nP2-nP1;

printf("nnThe Change in Quantity is %lfnn",nChgQ);
printf("nnThe Change in Price is %lfnn",nChgP);

nSec1 = (nQ1+nQ2) / 2;
nSec2 = (nP1+nP2) / 2;

nResult1 = nChgQ / nSec1;
nResult2 = nChgP / nSec2;

nElasticity = nResult1 / nResult2;

//result
printf("nn______________nn");
printf("The Price Elasticity of Demand is %lfnnnnn",nElasticity);

if(nElasticity==-1 || nElasticity==1)
{
printf("This is Unitary Elasticnnn");
}
if(nElasticity<1 && nElasticity>-1)
{
printf("This is Inelasticnnn");
}
if(nElasticity>1 || nElasticity<-1)
{
printf("This is Elastic");
}
if(nElasticity==0)
{
printf("Inelastic");
}

printf("nn______________________nnn");
printf("Do you want to quit? (y/n)  ");
scanf("%s", &quit);
printf("nnnn");
}
while (quit == 'N' || quit == 'n');

return 1;
}

```

Is This A Good Question/Topic? 0

Page 1 of 1

 .related ul { list-style-type: circle; font-size: 12px; font-weight: bold; } .related li { margin-bottom: 5px; background-position: left 7px !important; margin-left: -35px; } .related h2 { font-size: 18px; font-weight: bold; } .related a { color: blue; }