please how to write ?

firstly write a program to accept the number of telephone calls made by a customer and the print out the rate in cents.
What are you having trouble with? Have you written any code yet?
not yet, can you help me?
show us the code
then well help you
//Telephone calls

#include<stdio.h>
void main()
{
int n;
float k=n,temp,l,j;
clrscr();
printf("Enter the number of calls : ");
scanf("%d",&n);
if(n<=100)
{
printf("Amount to be paid is rate.%f",k);
}
else if(n>101&&n<=500)
{
temp=0.15;
k=k+temp;
printf("Amount To Be Paid Is %f",k);
}
else if(n>101&&n<=500)
{
j=0.2;
n=n-500;
temp=0.15*n;
k=k+temp+j;
printf("Amount to be paid is %f",k);
}
else if(n>501)
{
j=0.1;
l=0.15;
n=n-501;
temp=0.1*n;
k=k+j+l+temp;
printf("Amount To Be Paid Is %f",k);
}
getch();
}
You need to name your variables better. 'n' tells me nothing about what it's used for.

One problem I see is that you assign k to equal n before n equals anything. You're going to get garbage data if you do that.

ps: use Code Tags to format your code so we can read it - http://www.cplusplus.com/articles/jEywvCM9/
//Telephone bill

#include<stdio.h>
int main()

{
int n;
float k=n,temp,l,j;
printf("Enter the number of calls : ");
scanf("%d",&n);
if(n<=100)
{
printf("Amount to be paid is rate.%f",k);
}
else if(n>101&&n<=500)
{
temp=0.15;
k=k+temp;
printf("Amount To Be Paid Is %f",k);
}
else if(n>101&&n<=500)
{
j=0.2;
n=n-500;
temp=0.15*n;
k=k+temp+j;
printf("Amount to be paid is %f",k);
}
else if(n>501)
{
j=0.1;
l=0.15;
n=n-501;
temp=0.1*n;
k=k+j+l+temp;
printf("Amount To Be Paid Is %f",k);
}

}
Topic archived. No new replies allowed.