attempt to display an electricity bill that looks, for example, like this:
*********************************
Present meter reading 6015
previous meter reading 5899
Units used 116
Rate per unit 6.73 pence
Standing charge £7.78
The sum due is £15.59
*********************************

This program displays an electricity bill, given a present meter reading and a previous meter reading. The price per unit (in pence) and a fixed standing charge are constant. The units used and the sum due are to be calculated.

/* Electricity Bill 1 */ 
#include <stdio.h> 
 main () 
{ 
  int present, previous; 
  printf("Type present and previous meter readings:\n"); 
  scanf("%i%i", &present, &previous); 
  printf("****************************\n"); 
  printf("Present meter reading    %i\n", present); 
  printf("Previous meter reading   %i\n", previous); 
  printf("Units Used                 %i\n", present-previous); 
  printf("Rate per unit            6.73 pence\n"); 
  printf("Standing charge         £7.78\n\n"); 
  printf("%f\n", (present-previous)*6.73/100 + 7.78); 
  printf("****************************\n"); 
getch();
return 0;
}

the problem iam now facing is that i now want the standing charge and the rate per unit to be variable not fixed, in other words i want the program after running it to prompt me to enter the standing charge and the rate per unit.

Do you mean you want the values to be variable yet still persistent across runs of the program?

the problem iam now facing is that i now want the standing charge and the rate per unit to be variable not fixed, in other words i want the program after running it to prompt me to enter the standing charge and the rate per unit.

Create two floating point variables for charge and rate, and do same thing that you did for present and previous.

Hi,
Please be more specific... What is it that you are looking for? If you want the program to prompt the user to enter the Standing charger and Rate per unit, then you can do it just the way you are taking previous and present readings.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.